I am automating the creation of MS Word 2007 documents from MS Access 2007.
The word documents are templates (.dotx). They are password protected.
Using VBA, I need to pass through a password when I open the template. However, using my current method, I can't see any option of doing this. If I use the documents.open method, there is a password option however when I open the template this way, it opens the live template and not a copy.
Below is my current code, any help would be appreciated.
'Pass in a path and open a word doc
Sub openWordTemplate(sDocumentPath As String, sDocumentName As String)
Dim appWord As Word.Application
Dim appDocument As Word.Document
Set appWord = New Word.Application
appWord.Visible = False
'Commented out as this opens the live doc and not a copy of the template.
'Set appDocument = appWord.Documents.Open(sDocumentPath & sDocumentName, , , , TEMPLATE_PWD)
'Open the template. But where can I pass in the password?
Set appDocument = appWord.Documents.Add(sDocumentPath & sDocumentName)
End Sub