Frage

Ich versuche, MS Word aus meiner C # -Anwendung zu automatisieren und haben ein Problem Ändern der Band UI. Alle Proben, die ich finden konnte, verwenden IRibbonExtensibility-Schnittstelle, die von Add-Ins verfügbar ist ähnlich. Ist es möglich, diese mit Hilfe der Automatisierung zu tun?

War es hilfreich?

Lösung 2

What I did was to build small ATL Addin which implements 2 Interfaces: IDTExtensibility2 and IRibbonExtensibility The customization XML is simply loaded from file.

Inside the C# code the coding is really simple:

        RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Office\Word\Addins\RibbonLoaderLib.RibbonLoader");
        key.SetValue("LoadBehavior",2,RegistryValueKind.DWord);
        key.SetValue("Description","Ribbon Loader Add-In",RegistryValueKind.String);
        key.SetValue("FriendlyName","Ribbon Loader Add-In",RegistryValueKind.String);
        wordApp_.COMAddIns.Item("RibbonLoaderLib.RibbonLoader").Connect = true;           

Andere Tipps

using IRibbonExtensibility interface which is available from Addins only

Which means that it won't work through Automation, the interface is not exposed in the out-of-process type library. You'll have to use VSTO to write an add-in, use the C# + Office + Word 2007 Add-in project template to get started.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top