2016-09-30 77 views
0

我明白,可以简单地使用模板;但我正在考虑改变标题1的字体大小和颜色的可能性。是否可以使用c#interop.word更改文档内置样式?

我已经试过这样的事情

Style style = Globals.ThisAddIn.Application.ActiveDocument.Styles.Add("Heading 1"); 
style.Font.Name = "Verdana"; 
style.Font.Size = 36; 

上述表示的错误标题1是一个保存完好的名字。

我还发现一个提示是这样的:

ActiveDocument.Styles("Heading 1").AutomaticallyUpdate = True 
ActiveDocument.Styles("Heading 1").Font.Name = "Verdana" 

然而在上面;样式不是采取参数的方法。 我已经看过一些Styles类的成员,它似乎有properties来更改样式,如自动更新;但无法弄清楚如何解决问题。

因此,有可能使用c#interop.word将内置样式更改为不同的字体。

回答

1

是的,你可以...

在C#

Style style = ActiveDocument.Styles["Heading 1"]; 
style.Font.Name = "Segoe UI"; 
style.Font.Size = 48; 

在VBA

Dim stl As Style 
Set stl = ActiveDocument.Styles("Heading 1") 
stl.Font.Name = "Segoe UI" 
stl.Font.Size = 48 

现在,如果你键入标题1种样式的东西它会在濑越用UI大小48.