I am trying to dynamically add a new custom feed to a Word 2007 document by following the manual method described in this article: - http://msdn.microsoft.com/en-us/library/aa338202(v=office.12).aspx .
The article states the following: -
a) Create an XML file called customUI.xml that will contain the elements that you want to display on the tab and put the same in the folder named customUI.
b) Rename the Word 2007 document to .zip. Add the "customUI" folder above to the zip file.
c) Add the following message to the "_rels / rels" file in the .zip file: -
<Relationship Type="http://schemas.microsoft.com/office/2006/ relationships/ui/extensibility" Target="/customUI/customUI.xml" Id="customUIRelID" />
Do we have sample code for using the OpenKML SDK? For example, how to add a RibbonExtensibilityPart (which contains tape XML) to a document?
EDIT : -
Here is how I took the following steps: -
string documentFileName = <path of the docx file>; string ribbonXml = <path of the ribbon XML file>; using (WordprocessingDocument myDoc = WordprocessingDocument.Open(documentFileName, true)) { MainDocumentPart mainPart = myDoc.MainDocumentPart; if (myDoc.GetPartsCountOfType<RibbonExtensibilityPart>() > 0) myDoc.DeletePart(myDoc.GetPartsOfType<RibbonExtensibilityPart>().First()); RibbonExtensibilityPart ribbonExtensibilityPart = myDoc.AddNewPart<RibbonExtensibilityPart>(); ribbonExtensibilityPart.CustomUI = new DocumentFormat.OpenXml.Office.CustomUI.CustomUI(File.ReadAllText(ribbonXML)); myDoc.CreateRelationshipToPart(ribbonExtensibilityPart); }
and I can see a new ribbon with elements in it. However, I have buttons on the ribbon, and I want to add controls on these buttons. The following is an example of my XML feed: -
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab id="CustomTab" label="My Tab"> <group id="MyGroup" label="My Group" > <button id="Button1" label="My Large Button" size="large"/> <button id="Button2" label="My Normal Button" size="normal" *onAction="ThisDocument.MyOtherButtonMacro"* /> </group > </tab> </tabs> </ribbon> </customUI>
take a look at β onAction =" ThisDocument.MyOtherButtonMacro . I know that I can write a macro function in a document. However, since the user feed will be dynamically added on the server side, I'm not sure how I can add the macro dynamically. Can anyone to help?