In my database, I want to open a new word document using a specific template that has macros in it. The template contains a custom menu bar and many quick parts. If I open the document as a macro-enabled template, the ribbon is displayed, and the quick parts are there, and everything works. After the user works with the document and finished their edits, I'd like to automatically save the document as a word document.
So, while the document is created from access and being used in word, I need the macro enabled document in order to use the custom menu bar and commands. But when the document is saved, it needs to be saved as a plain .docx so that it can be retrieved later. Currently, if the document is not closed with a Save As command, the document will not open because the extension is .docx, but the file type is .dotm which causes an error stating "Word encountered an error processing the XML file filename.docx"
Currently, I am creating the document from Access and taking some information from the database and placing it in the word document. I'm trying to not have the user execute a Save As command when finished.
opening Word document using template
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA
opening Word document using template
Cordially,
Bob Sullivan
Elverson, PA
Bob Sullivan
Elverson, PA
-
- Administrator
- Posts: 78629
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: opening Word document using template
You should open the document by using the Documents.Add method of the Word.Application object, not Documents.Open. Something like (simplified):
Code: Select all
Dim wrdApp As Object
Dim wrdDoc As Object
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Add("path and filename.dotm")
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA