G
gch31
I am trying to create a Word document with the following code.
The exercise calls for Winword.exe to be in the default location (C:\Program
Files) but Winword.exe is installed in E:\Program Files.
How can I tell Access the location of Winword.exe
Thanks in advance
Public Function CreateWordMemo()
' Open a memo in Word and insert text - used by menu command.
Dim rstEmployees As New ADODB.Recordset
Dim appWord As New Word.Application
' Open a recordset based on the EmployeesWithOpenIssues query.
rstEmployees.Open "EmployeesWithOpenIssues", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no one has open issues, display a message and exit.
If rstEmployees.RecordCount = 0 Then
DisplayMessage "There are no open issues to announce."
' Open a document based on the memo template, turn off spellcheck,
' move to the MemoToLine bookmark, and then display Word.
With appWord
.Documents.Add "E:\Access Visual Basic\Memo.dot"
.ActiveDocument.ShowSpellingErrors = False
.Selection.GoTo wdGoToBookmark, Name:="MemoToLine"
.Visible = True
End With
' Loop through the recordset returned by the query,
' inserting the name of each employe into the document.
Do Until rstEmployees.EOF
appWord.Selection.TypeText rstEmployees!EmployeeName & " "
rstEmployees.MoveNext
Loop
Exit Function
End If
End Function
The exercise calls for Winword.exe to be in the default location (C:\Program
Files) but Winword.exe is installed in E:\Program Files.
How can I tell Access the location of Winword.exe
Thanks in advance
Public Function CreateWordMemo()
' Open a memo in Word and insert text - used by menu command.
Dim rstEmployees As New ADODB.Recordset
Dim appWord As New Word.Application
' Open a recordset based on the EmployeesWithOpenIssues query.
rstEmployees.Open "EmployeesWithOpenIssues", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no one has open issues, display a message and exit.
If rstEmployees.RecordCount = 0 Then
DisplayMessage "There are no open issues to announce."
' Open a document based on the memo template, turn off spellcheck,
' move to the MemoToLine bookmark, and then display Word.
With appWord
.Documents.Add "E:\Access Visual Basic\Memo.dot"
.ActiveDocument.ShowSpellingErrors = False
.Selection.GoTo wdGoToBookmark, Name:="MemoToLine"
.Visible = True
End With
' Loop through the recordset returned by the query,
' inserting the name of each employe into the document.
Do Until rstEmployees.EOF
appWord.Selection.TypeText rstEmployees!EmployeeName & " "
rstEmployees.MoveNext
Loop
Exit Function
End If
End Function