In Word 2010 the new styles are created automatically, I woul开发者_StackOverflow社区d like to suppress this behaviour. For eg: the text with style "Heading 1" after formatting say ctrl+B to remove the bold, the Word creates a new style called "Heading 1 + Not Bold"
Actually I want to switch oof this behaviour from VSTO at application level. Any help would be appreciated?
Actually, Word is not creating new styles but is displaying (within the Styles Pane) styles that also have direct formatting (which is formatting applied after the application of a style). The Options link on the bottom of the Styles Pane will display the below dialog box, which contains the style display choices:
To turn off the display of direct formatting via VBA (which can be adapted for VSTO depending on the language you are using):
'Turn off display of character direct formatting
ActiveDocument.FormattingShowFont = False
'Turn off display of paragraph direct formatting
ActiveDocument.FormattingShowParagraph = False
Additionally, one can control which styles are displayed with the FormattingShowFilter
property. For example, to only display the styles in use in the active document:
ActiveDocument.FormattingShowFilter = wdShowFilterStylesInUse
Hope this helps.
You might also uncheck "paragraph level formatting" in the Style Pane Options dialog box. Turning off both font and paragraph "formatting to show" is the only way I can use Word. Otherwise, the direct formatting added by multiple authors obscures the styles you really want.
The answers provided affect the display, but not the root behaviour of Word. If you want to suppress this behaviour at the application level set the Application option to Keep Track of Formatting to off (Tools > Option > Advanced > Editing Options > Keep track of formatting.).
File / Options / Proofing / Auto Correct Options... (button) / AutoFormat As You Type (tab) / uncheck Define styles based on your formatting
精彩评论