Word document Event Procedure error

staholly

Registered User.
Local time
Today, 16:50
Joined
Jul 14, 2011
Messages
16
Getting an error when attempting to use data from access in word document. The error says "Word was unable to read this document. It may be corrupt. Try one or more of the following: Open and repair the file. Open the file with the Text Recovery converter."
The document doesn't have an issue when I open it through word itself, only when I trying running the event procedure in access(I am using Office 2003 sp3). This is what I have written.

Private Sub cmdTransferToWord_Click()
On Error GoTo Err_cmdTransferToWord_Click
Dim oWord As New Word.Application
With oWord
.Documents.Add "Film details.dot"
.Selection.GoTo wdGoToBookmark, , , "bmkFilmTitle"
.Selection.TypeText Me.FilmTitle.Value & "(" & Me.FilmYearReleased.Value & ")"
.Selection.GoTo wdGoToBookmark, , , "bmkDirector"
.Selection.TypeText Me.DirectorFullName.Value
.Selection.GoTo wdGoToBookmark, , , "bmkstudio"
.Selection.TypeText Me.Studio.Value
.Selection.GoTo wdGoToBookmark, , , "bmkRating"
.Selection.TypeText Me.Rating.Value
.Selection.GoTo wdGoToBookmark, , , "bmkMedia"
.Selection.TypeText Me.Media.Value
.Selection.GoTo wdGoToBookmark, , , "bmkPlotOutline"
.Selection.TypeText Me.FilmPlotOutline.Value
.Selection.GoTo wdGoToBookmark, , , "bmkReview"
.Selection.TypeText Me.FilmReview.Value
.Visible = True
End With
Exit_cmdTransferToWord_Click:
Exit Sub
Err_cmdTransferToWord_Click:
MsgBox Err.Description
Resume Exit_cmdTransferToWord_Click

End Sub
 
.Documents.Add "Film details.dot"
I don't do Word automation but shouldn't you be using the FULL path to the document there?

Also, when you want to debug code, take out the error handler. That is, comment out this code line:

'
On Error GoTo Err_cmdTransferToWord_Click

By the way, you probably would have gotten a response quicker if you had posted in the Word section of the forum.
 
I'm not having a problem when opening in word only when I attempt to run this code in Access.
 
Did you read what I mentioned about putting the full path there?
 

Users who are viewing this thread

Back
Top Bottom