I have this code which works but I want to expand on it.
What I want to do is put data into the document at bookmarks. I have these bookmarks set in the .dot already. Can anyone point me to an example? Thanks.Code:Private Sub Print_Template() On Error GoTo ERRHANDLE Dim objWord As Object 'Set objWord = Word.Application Dim strFileName As String Set objWord = CreateObject("Word.Application") strFileName = "invoice1.doc" With objWord .Documents.Open (App.Path & "\invoicetemplate.dot") .ActiveDocument.SaveAs (App.Path & "\" & strFileName) .Application.Documents.Close End With objWord.Quit Set objWord = Nothing Exit Sub ERRHANDLE: ErrorCode = Err.Number ErrorDesc = Err.Description MsgBox Str(ErrorCode) + ErrorDesc Resume Next End Sub
Also should the objWord.Quit statement be inside the With?




Reply With Quote