0
votes

I have a VB.NET program which opens word documents, performs a mail merge and then saves them to a different location. I am now attempting to allow the user to decide when they want to save the document via adding a button to the ribbon in word which calls a macro to do this.

I've created a docm template which adds the button to the ribbon in Word 2007/2010/2013. On attempting to open any doc/docx file however Word will always open it in a new window which lacks the ribbon modification imposed by the template.

I was wondering if anybody knew of a way to programmatically apply a template to an existing document short of opening the docm file and pasting in all the text from the doc/docx file?

1

1 Answers

0
votes

If I understand you correctly, the macro (button) is part of the template and is visible as far as the currently open document is using/based on that template. So, opening an existing document based on another template (that doesn't define the macro) will not show the macro button. "Applying a new template to an existing documents" doesn't really makes sense because templates have their role only when a new document is born. At that moment all styles, content gets copied from the template into the new document and after that any connection with the template is lost.

I do not see other solution for you other than creating an Application level Add-In for MS Word. Your clients will have to install the Add-In but after that the required functionality will be always accessible from the Ribbon. Of course this solution is a more expensive one compared to your current one because you will have to create an Add-In application (not so difficult) as well as installer (MSI setup) for the Add-In (can be difficult without any previous exepriences).