Click here to Skip to main content
14,449,862 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.
Is there any solution? Or was I unable to make things clear?
Please, any reply is appreciated.
Thanks,
Prabhat
Posted
Updated 26-May-13 15:58pm
v4
Comments
Zoltán Zörgő 26-May-13 5:53am
   
Why don't you make it so from the very beginning? Why do you need to change it after you constructed the document? Have you considered using styles?
PrabhatSharp 26-May-13 6:00am
   
Thanks zoltan for the reply. My requirement is that, the company's name in the top should be in 12pt while rest of the contents like Username and Phone No should be in 21 pt.
Thank you.
David_Wimbley 26-May-13 23:53pm
   
Can you post some code so we can see what your doing? My crystal ball is out of service.

My first guess without seeing anything is to take whatever code you currently have that sets the font to 21pt, slap it into a method/class/static method something....then have a parameter for that method be the font size and tah dah. But again, without seeing your code thats the best i got...
PrabhatSharp 27-May-13 0:28am
   
Thanks David. Below is my code:
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++)//TotalNumber is some number
{
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;
}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100