How to use Heading Style while automating word in C#?
My program is copying string from other file and it should convert as heading while pasting in word. (MS 2007). I tried recording macro:
Selection.PasteAndFormat (wdPasteDefault)
Selec开发者_开发百科tion.Style = ActiveDocument.Styles("Heading 2").
But how to do it in C#?
Ok this is what I did:
object headingType = Word.WdBuiltinStyle.wdStyleHeading2;
wordApp.ActiveWindow.Selection.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault);
wordApp.ActiveWindow.Selection.Range.set_Style(ref headingType);
精彩评论