VSTO document-level 自定义拦截命令
VSTO document-level customization Intercept Commands
我们目前正在使用 C# VSTO document-level 自定义构建一组企业模板。我们需要拦截粘贴命令并在粘贴到文档之前更改内容。例如,如果用户粘贴图像,我们也会插入一个标题,或者如果用户粘贴 table,它会被适当地格式化。我们如何拦截这个事件?能不能通用一下,让我们也能看到其他命令?
谢谢
您可能必须使用重新调整用途的命令。这里是 how to
在Ribbon.xml
<commands>
<command idMso="Paste" onAction="CustomPaste"/>
</commands>
在Ribbon.cs
public void CustomPaste(Office.IRibbonControl control, bool cancelDefault)
{
//Globals.ThisAddin.Application.Selection.Paste();
//Check if the pasted content is image and then add caption to it
}
我们目前正在使用 C# VSTO document-level 自定义构建一组企业模板。我们需要拦截粘贴命令并在粘贴到文档之前更改内容。例如,如果用户粘贴图像,我们也会插入一个标题,或者如果用户粘贴 table,它会被适当地格式化。我们如何拦截这个事件?能不能通用一下,让我们也能看到其他命令?
谢谢
您可能必须使用重新调整用途的命令。这里是 how to
在Ribbon.xml
<commands>
<command idMso="Paste" onAction="CustomPaste"/>
</commands>
在Ribbon.cs
public void CustomPaste(Office.IRibbonControl control, bool cancelDefault)
{
//Globals.ThisAddin.Application.Selection.Paste();
//Check if the pasted content is image and then add caption to it
}