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...

Lalit MRank #1,186 · 1.5K reputationPosted Feb 3, 2010, 6:56 PM EST
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx
Mel Jos3 reputationPosted Feb 3, 2010, 7:06 PM EST
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
harry peter7 reputationPosted Jul 20, 2010, 6:11 AM EDT
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.