This is from some code I use - I stripped out the code that takes info from the current record displayed on a form to populate the word.doc . hope it helps.
Private Sub CmdOpenWordDoc_Click()
On Error GoTo ErrorHandler
Dim appWord As Word.Application
Dim docs As Word.Documents
Dim strLetter As String
Dim strTemplateDir As String
Dim strDate As String
Dim Obgor As String
Set appWord = GetObject(, "Word.Application")
strDate = CStr(Date)
Rem OPTIONAL - change path from user template dir and force to a controlled location if there is a special template required:
strTemplateDir = "C:\path\"
With appWord
.Visible = True
.Activate
.Selection.WholeStory
.Selection.Fields.Update
.Selection.MoveDown Unit:=wdLine, Count:=1
.ActiveDocument.Protect wdAllowOnlyFormFields
End With
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err = 429 Then
'Word is not running; open Word with CreateObject
Set appWord = CreateObject("Word.Application")
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
My last post might not work for you - Actually this is a bit cleaner and less confusing - can open a new blank word doc (point to the template name.dot) or an existing doc:
Dim oApp As Object
Dim oDoc As Object
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set oDoc = oApp.Documents.Open("full path to file or template you want to open"
I have tried the word wizard but it just opens word itself not the form. And I have also tried assigning a hyperlink address the form opens only after the hyperlink warning. can I get that to not show the warning? Thanks all for helping. Kraig
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.