This is the way we do it when we want to manipulate the data in the document, put some values in a table, create a table, do a Find and replace, text formatting absolutely anyting you can do yourself in word manually you can code here.
Code:
Dim objWordApp As Word.Application
Dim objDoc As Word.Document
Set objWordApp = CreateObject("Word.Application")
' turn off autorecover save
objWordApp.Options.SaveInterval = 0
' turn off prompt for saving to normal template
objWordApp.Options.SaveNormalPrompt = False
objWordApp.Options.SavePropertiesPrompt = False
' make word visible for development purposes or invisible to the users
objWordApp.Visible = True
objWordApp.WindowState = wdWindowStateNormal
With objWordApp
.Documents.Open App.Path & "\DDTemplate.doc", False, True, False, , , True
Set objDoc = .Documents(.ActiveDocument.Name)
End With
With objDoc
.BuiltInDocumentProperties(wdPropertyTitle) = strTable
.BuiltInDocumentProperties(wdPropertySubject) = txtTableDesc.Text
.Fields.Update
End With
'...
'
' do some stuff here
' anything to manipulate the document contents
'...
objDoc.PrintOut False, , wdPrintAllDocument, , , , , Copies:=CInt(txtCopies)
objDoc.Close SaveChanges:=wdDoNotSaveChanges
objWordApp.Quit
Set objWordApp = Nothing