Word Automation using C#
Hi All,
I need some urgent help about how to make only a portion of a paragraph be applied a particular style. I am using word automation using c# to generate a word document out of a MS word template file.
I tried the below method which is supposed to select between two bookmarks and apply the style to the selection.. But couldn't get it working..
The entire para gets applied with the style
object oBMRangeStart = "BMStart";
object oRngBMStart = oDoc.Bookmarks.get_Item(ref oBMRangeStart).Range.Start;
object oBMRangeEnd = "BMEnd";
object oRngBMEnd = oDoc.Bookmarks.get_Item(ref oBMRangeEnd).Range.Start;
Word.Range rngBM = oDoc.Range(ref oRngBMStart, ref oRngBMEnd);
rngBM.Select();
object oStyleName = "Style1";
rngBM.set_Style(ref oStyleName);
Any help will be greatly appreciated....
Thanks in advance...
harry peterPosted Jul 20, 2010, 10:11 AM
Microsoft does not recommend using Office application in server-side scenarios. If you want to use 3rd party .net word document components, Spire.Doc can do make only a portion of a paragraph be applied a particular style. it easy and fast, i use it from last year, work quit good.
http://www.e-iceblue.com/Introduce/word-for-net-introduce.html
hope help with you.
Mel JosPosted Feb 4, 2010, 12:06 AM
But it's not working as i expected... the entire Para is getting bold...
Is there any other method by which the requirement be achieved?
Thanks
Lalit MPosted Feb 3, 2010, 11:56 PM
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx