Hi!
I'm getting an error when I call the function CreateWordMemo. It breaks at line: .Documents.Open "c:\ch14 memo.dot" I have replaced it with .Documents.Add "c:\ch14 memo.dot" but I get the same error.
Now the strange part: When I set a breakpoint at the beginning of the code and I step through it, line by line, it doesn't give the error!
Am I doing something wrong or is something wrong in the setup of Access/Word?
This is the error I'm getting (I'm using the dutch version of Office, so I translated the error):
"Error -2147417851 (80010105) during the presentation:
Method Open of object Documents failed"
Something interesting: Word DOES start, it only doesn't load the template. When I close word Windows XP says that word has has an fault ans shall be closed. The next time I want to open the template, word tries me to beleve it's the fault of the template that word crashed, but nothing's wrong with the template!
I hope someone can help me. I'm using Access XP, Word XP and Windows XP PRO.
Greetz, Tom
this is the code:
Public Function CreateWordMemo()
' Open a memo in Word and insert text - used by menu command.
' Declarations
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."
Exit Function
End If
' Open document in word, goto bookmark
With appWord
.Visible = True
.Documents.Open "c:\ch14 memo.dot"
.ActiveDocument.ShowSpellingErrors = False
.Selection.GoTo wdGoToBookmark, Name:="MemoToLine"
End With
' insert employee names in memo
Do Until rstEmployees.EOF
appWord.Selection.TypeText rstEmployees!EmployeeName & " "
rstEmployees.MoveNext
Loop
' Save word document
appWord.ActiveDocument.SaveAs "C:\tom3.doc"
' close the word document
appWord.ActiveDocument.Close
'close word
appWord.Quit
End Function
I'm getting an error when I call the function CreateWordMemo. It breaks at line: .Documents.Open "c:\ch14 memo.dot" I have replaced it with .Documents.Add "c:\ch14 memo.dot" but I get the same error.
Now the strange part: When I set a breakpoint at the beginning of the code and I step through it, line by line, it doesn't give the error!
Am I doing something wrong or is something wrong in the setup of Access/Word?
This is the error I'm getting (I'm using the dutch version of Office, so I translated the error):
"Error -2147417851 (80010105) during the presentation:
Method Open of object Documents failed"
Something interesting: Word DOES start, it only doesn't load the template. When I close word Windows XP says that word has has an fault ans shall be closed. The next time I want to open the template, word tries me to beleve it's the fault of the template that word crashed, but nothing's wrong with the template!
I hope someone can help me. I'm using Access XP, Word XP and Windows XP PRO.
Greetz, Tom
this is the code:
Public Function CreateWordMemo()
' Open a memo in Word and insert text - used by menu command.
' Declarations
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."
Exit Function
End If
' Open document in word, goto bookmark
With appWord
.Visible = True
.Documents.Open "c:\ch14 memo.dot"
.ActiveDocument.ShowSpellingErrors = False
.Selection.GoTo wdGoToBookmark, Name:="MemoToLine"
End With
' insert employee names in memo
Do Until rstEmployees.EOF
appWord.Selection.TypeText rstEmployees!EmployeeName & " "
rstEmployees.MoveNext
Loop
' Save word document
appWord.ActiveDocument.SaveAs "C:\tom3.doc"
' close the word document
appWord.ActiveDocument.Close
'close word
appWord.Quit
End Function