I have created a Word document using VBA in Access by creating a new Word.Application, importing a document with Documents.Add and then making the desired changes. Once the chan
This is what I came up with some years ago. It also sets .BuiltInDocumentProperties(wdPropertyTitle)
.
The key is to use, but not show, oWord.Dialogs(wdDialogFileSummaryInfo)
.
' Window title
sWindowTitle = "Document for " & sName
' http://wordmvp.com/FAQs/MacrosVBA/SetDefFilename.htm
With oWord.Dialogs(wdDialogFileSummaryInfo)
' Several characters will cause Word to truncate the default file name when saving
sClean = sWindowTitle
sClean = Replace(sClean , ".", "") ' Dr. John Smith
sClean = Replace(sClean , "-", " ") ' Anne-Marie Jones
' ... expand as needed ...
.Title = sClean
.Execute
End With
With oDoc
.ActiveWindow.Caption = sWindowTitle
End With