问题
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