Deploy Dotm File with format styles?

大兔子大兔子 提交于 2019-12-12 05:28:37

问题


I have developed a small VBA macro for Word 2007 / 2010 which uses some format styles (I am not sure that is the best translation, in my german version it is called Formatvorlagen. I mean the styles which are applied to text, like headers).

The macro is deployed to the STARTUP Folder and essentially works - but the format styles are NOT loaded - so the macro cannot find them.

So my question is: how can I deploy format styles to Word? I could overwrite normal.dot, but that is a crappy solution.


回答1:


There's probably an easier way that I cannot think of at the moment, but you could try the following:

Export the styles you want by clicking the Change Styles button on the Home tab, selecting Style Set and Save as Style Set.

The command will save the currently selected style set as a dotx file. The default location is C:\Users\[USERNAME]\AppData\Roaming\Microsoft\QuickStyles - if you copy the file to a new computer and put it in the same directory for the user, you can then load the style set with the Change Styles button or in code:

ActiveDocument.ApplyQuickStyleSet2 "XXX"

where XXX is the name of the style as seen under the Change Styles button (the same as the styles filename without the dotx extension).



来源:https://stackoverflow.com/questions/15242041/deploy-dotm-file-with-format-styles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!