开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜