Font Size via C#

May 26 2013 11:14 PM
I have created a table(in MsWord using C#) with multiple rows and 2 columns. I have inserted text inside each column. For all cases there's one common text, "Welcome to XYZ Company". Now, my problem is, I want its size to be 12 while rest of the text size should be 21 pt. I assigned 21pt size for rest of the text, but want to know a way to insert another text in the same table with different size. My code is below:


 Microsoft.Office.Interop.Word.Table tbl1;
 Microsoft.Office.Interop.Word.Range wordRange = doc.Content;
  tbl1 = doc.Content.Tables.Add(wordRange, 3, 2, ref objMiss, ref objMiss);//3 columns, 2 rows
 tbl1.Borders.Enable = 1;

  int cc = 1;
           for (int r = 1; r <= TotalNumber; r++)
                {
                    for (int c = 1; c <= 2; c++)
                    {

                                if  (cc < UserNameOne.Length) //UserNameOne is a String Collection
                        {
                         tbl1.Cell(r, c).Range.Text = "Welcome to XYZ Company\n" + "User Name:" +                                         UserNameOne[cc] + "\n" ;//I want the size of "Welcome to XYZ Company" to be 12 pt
                            tbl1.Cell(r, c).Range.Font.Bold = 0;
                            tbl1.Cell(r, c).Range.Font.Size = 21;
                             cc = cc + 1;
                           }
                    }


Answers (14)