Reputation: 43
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)
Selection.Style = ActiveDocument.Styles("Heading 2").
But how to do it in C#?
Upvotes: 0
Views: 2483
Reputation: 43
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);
Upvotes: 1