Word Merge Errors

C

Craig

I am attempting to do mail merges with different Word documents. I have a
function set up call MailMerge passing the query string and Word document
name. It worked for a single merge before I put in variables for the multiple
documents to be merged. Below is the code:
sPath = GetTableConnectString("BidInformation")
sDBPath = Left$(sPath, Len(sPath) - 11) & "DES.mdb"
i = InStr(1, sPath, "DESdata.mdb")
sFileName = Left$(sPath, i - 1)
Debug.Print sDBPath

sFileName = sFileName & DocumentName
Debug.Print sFileName
Set Wd = New Word.Application

Wd.Visible = True

'Start a new main document for the mail merge.
Set Doc = Wd.Documents.Open(sFileName)

With Doc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:=sDBPath, SQLStatement:="SELECT * FROM [" &
QueryName & "]"
.Destination = wdSendToNewDocument
.Execute Pause:=False
End With

The filename and db path variables are correct. When the code starts up Word
I get the Datalink Properties window. It show an Admin user w/o a password. I
click OK and then I get a Login screen and then I get an ODBC Microsoft
Access Driver Login Failed error message. This used to work for me. Any help
appreciated.
 

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