开发者

Disable Word 2010 commands on a document level

开发者 https://www.devze.com 2023-01-09 20:50 出处:网络
We want to disable any and all formatting and insertion commands in Word except for bold and italic in all documents that are created from a certain template. It should not be possible to change style

We want to disable any and all formatting and insertion commands in Word except for bold and italic in all documents that are created from a certain template. It should not be possible to change styles, insert anything but text, or change character formatting at all (except for the aforementioned bold and开发者_如何学C italic formats). Is there a way to achieve this?

Maybe it would be possible to disable these commands with a VBA autostart macro in the template?


The only way would be to hook the WindowSelectionChange(ByVal Sel As Selection) event and catch any change that is not a character, bold format or italic format. I guess it would be a fair amount of coding to set this up.


I figured out how to do this with RibbonX. For example, to disable the bold command, add this RibbonX XML to the document or template:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <commands>
        <command idMso="Bold" enabled="false"/>
    </commands>
</customUI>

Of course, the user can still paste bold text.

0

精彩评论

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

关注公众号