Run-time error '5992': Word was unable to open the data source

M

mjokins

Help. I'm a student in college taking a vba programming class and I'm
receiving the following error message:

Run-time error '5992': Word was unable to open the data source

The book is for Office 2000, but we're using Office XP. I've talked to
the teacher and my fellow students and they're all having this
problem. I'm hoping someone could give me a few suggestions on what
the problem is and how to fix it. The code is listed below where the
error is in bold text. I will be most thankful to anyone that can help
me with this problem, because it will bug the heck out of me until
it’s fixed. Thanks.



mjokins



Private Sub cmdOk_Click()

'declare variables and assign address to Document object variable

Dim blnOpen As Boolean, strFileName As String, docClient As
Document, tblClient As Table

Set docClient = Application.Documents("client list.doc")

'display trainer name in document

docClient.Paragraphs(6).Range.Text = _

"Trainer:" & vbTab & txtTrainer.Text & vbNewLine

'delete existing tables

For Each tblClient In docClient.Tables

tblClient.Delete

Next tblClient

'get the name of the Access database

With Application.Dialogs(wdDialogFileOpen)

.Name = "*.mdb"

blnOpen = .Display

strFileName = .Name

End With

If blnOpen = True And Right(strFileName, 4) = ".mdb" Then

'insert database information

Selection.EndKey unit:=wdStory

Selection.Range.InsertDatabase Format:=wdTableFormatClassic2,
Style:=63, _

connection:="table client", DataSource:=strFileName

If UCase(txtPrint.Text) = "Y" Then

Application.Dialogs(wdDialogFilePrint).Show

End If

End If

'unload the form

Unload frmClientList

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top