Last post Sep 27, 2012 04:57 AM by sureshr12
Sep 25, 2012 10:11 AM|aykut.bulut|LINK
Hi, I really am new to the interop. So far i've created a document and write paragraphs into a word document but cannot write a line with 2 different formats (bold, italic, etc.)
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "Heading 1";
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
I've found some results on the net but could not find a solution that i understand.
Any help would be appreciated. Thanks.
Sep 25, 2012 12:41 PM|gerrylowry|LINK
aykut.bulut welcome to forums.asp.net
Please note: when it's not obvious how your question relates to ASP.NET, you should explicitly tell your peers here at forums.asp.net the connection to developing for ASP.NET; the focus of these forums is ASP.NET. other forums such as stackoverflow
regarding your question, i do not know the answer off the top of my head ...
FWIW, the approach that i would take would be to use Word's macro recorder which generates VBA ... i would then clean up the VBA macro, if necessary -- once the VBA was working to my satisfaction, i would translate it to c#.
Sep 25, 2012 06:25 PM|Paul Linton|LINK
You know that installing Office on a server is unsuported and will result in tears before bedtime, right?
You don't seem to have any statements which refer to 'italic', could this be the reason that text is not appearing as italic?
Never having used Word interop I would suggest
oPara1.Range.Font.Italic = 1;
Sep 27, 2012 04:57 AM|sureshr12|LINK
Hi, you canuse like this,
Word.Paragraph oPara = oDoc.Content.Paragraphs.Add(ref oMissing);oPara.Range.Text = "hello planet earth here's what I want to do";object oStart = oPara.Range.Start + 13;object oEnd = oPara.Range.Start + 18;Word.Range rBold = oDoc.Range(ref oStart, ref oEnd);rBold.Bold = 1;