3
Answers

Word Automation using C#

Mel Jos

Mel Jos

14y
7.8k
1

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

Answers (3)