I have a VBA script that, when ran, allows the user to open up a range of documents, then a UserForm appears. After the text boxes on the UserForm are filled out, the data is then used to create a Footer on the documents that the user selected. I currently have this saved as a docm. If I create a button in the Ribbon to run this Macro, how do I go about bundling the whole thing together into one template that I can share with user's in my company? We currently run Office O365.
I'm aware that this can be done with a dotm file. Do I just save the docm as a dotm (are there any extra steps needed to convert to dotm)? How do I get the dotm to contain both the macro and the button in the ribbon that will run it?
I am very new to VBA scripting and coding in general (only been at it for about 2 weeks) so I'm not really up on all the terminology. I've seen some how-tos online that involve adding XML code to the docm but I can't figure out how to apply what they are doing to my specific situation.
The end result I'm looking for is to have a dot or dotm file that I can copy to the users' STARTUP file in word and it have the macro button loaded into the ribbon automatically.
Currently I have changed the dotm file to a zip file and I have added a customui.xml file to the zip file. Then I turn I removed the zip extension turning it back into a dotm. Here is the code that I have for the customui.xml file (I've also tried removing the "mso:" from each line but it still doesn't work):
<mso:cmd app="Word" dt="0"/>
<mso:customUI xmlns:x1="http://schemas.microsoft.com/office/2009/07/customui/macro" xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
<mso:ribbon>
<mso:qat/>
<mso:tabs>
<mso:tab id="mso_c1.F7BE67B" label="HFA" insertBeforeQ="mso:TabInsert">
<mso:group id="mso_c2.F7BE67B" label="Footer" autoScale="true">
<mso:button idQ="x1:openAllfilesInALocation_0_F7D1806" label="Create Footer" imageMso="ListMacros" onAction="openAllfilesInALocation" visible="true"/>
</mso:group>
</mso:tab>
<mso:tab id="mso_c1.59115D6" label="HFA Footer" insertBeforeQ="mso:TabDeveloper">
<mso:group id="mso_c2.59115D6" label="Footer Creation" imageMso="FrameCreateAbove" autoScale="true">
<mso:button idQ="x1:openAllfilesInALocation_0_594B1AA" label="Create Footer" imageMso="FrameCreateAbove" onAction="openAllfilesInALocation" visible="true"/>
</mso:group>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>
Here is the code from the .rels file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
<Relationship Id="someID" Type="http://schemas.microsoft.com/office/2009/relationships/ui/extensibility" Target="customUI/customUI.xml"/>
</Relationships>
When I add this dotm file to C:\Users\username\AppData\Roaming\Microsoft\Word\STARTUP it does not add the custom button to the ribbon, however the macro is present.