我开发了一个插件来控制Office 2016中指定菜单和功能区控件的启用状态。
XML文件遵循以下格式:
<?xml version="1.0" encoding="utf-8" ?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<commands>
<command idMso="FileSendAsAttachment" enabled="false"/>
<command idMso="FileEmailAsPdfEmailAttachment" enabled="false"/>
<command idMso="FileEmailAsXpsEmailAttachment" enabled="false"/>
<command idMso="FileInternetFax" enabled="false"/>
...
</commands>
<ribbon>
</ribbon>
<backstage>
</backstage>
</customUI>安装加载项后,根据策略,代理可能需要临时启用某些菜单。因此,我只修改了XML文件中控件的enable属性,并重新启动了Office,但所有菜单都已启用。(但是,当我将其替换为原始XML文件时,它再次被标记为禁用。)
我的插件是通过regsvr32.exe注册的,注册表是用HKCU编写的。(Windows是64位,Office 2016是32位。)
有没有人遇到过类似的问题?是什么导致了这种情况?
发布于 2020-03-17 12:50:39
安装插件后,我使用记事本修改了XML文件。我发现它是以utf-8编码的方式存储的。
我注意到格式被破坏了,因为BOM被插入到XML文件的第一个字节中。如果将文件另存为ANSI,则可以正常工作。
我希望你不要犯和我一样的错误!
发布于 2020-03-17 18:25:46
使用utf-16
<commands>
<command idMso="FileSendAsAttachment" enabled="false"/>
<command idMso="FileEmailAsPdfEmailAttachment" enabled="false"/>
<command idMso="FileEmailAsXpsEmailAttachment" enabled="false"/>
<command idMso="FileInternetFax" enabled="false"/>
...
</commands>
<ribbon>
</ribbon>
<backstage>
</backstage>
</customUI>https://stackoverflow.com/questions/60704594
复制相似问题