Merge Error 5535

P

Pauline

When creating a mail merge I get this message "Error 5535 Could not finish
merging these documents or insterting this database" Then I am asked to debug
or end. If I debug I get Visual Basic and the following is highlighted
"objDoc.MailMerge.Execute". If I choose the end option it goes to the merged
document and all of the merged documents aren't there.
I have not idea what this means or where to start to fix it. Can anyone help
me?
Thanks
Renita
 
D

Doug Robbins - Word MVP

Show us the whole of the code that includes the command
objDoc.MailMerge.Execute

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Pauline

Here is the code

' BFE 4/25/07 XXXXXX. Change the macro to work in the current directory,
rather than
' hardcoded to C:\Datatel. Also update from the old Word95 basic code.

' This macro is linked to the Alt-M key. It will open DATATEL.DOC, which was
just downloaded
' to the client PC, update the merge data source to DATATEL.TXT which was
also just downloaded,
' and then run the merge.
Public Sub MAIN()
Dim objDatatelDot As Word.Document
Dim objDoc As Word.Document
Dim strCurPath As String

' Save object pointer to this document, so we can close it later
Set objDatatelDot = ActiveDocument

' Get path of this document
strCurPath = ActiveDocument.Path
If Right(strCurPath, 1) <> "\" Then strCurPath = strCurPath & "\"

' DATATEL.DOC and this document are in the same directory, which may vary
from user to user.
Set objDoc = Documents.Open(strCurPath & "DATATEL.DOC")

' DATATEL.DOC was setup with merge data source HEADER.DOC, which contained
only the field names.
' Now switch it to DATATEL.TXT, which will have the actual data.
DATATEL.TXT has been downloaded
' to the same directory as this document.
' (Why not just DATATEL.TXT for both setup and actual merge? Makes sense,
but need to keep this
' method now for backward compatibility.)
' LinkToSource means requery the data source each time this doc is opened.
objDoc.MailMerge.OpenDataSource Name:=strCurPath & "DATATEL.TXT",
LinkToSource:=True

' Run the merge
objDoc.MailMerge.Execute

' Close DATATEL.DOC and DATATEL.DOT. The new document created by the merge
will still be open.
' These Files are deleted by Colleague as soon as the user indicates the
merge is complete,
' but save in case the user wants to save them before returning to
Colleague.
' 10/09/2007 AHH XXXXXXXXXXXXX / ENV_SCR_15958
' Both objDoc.Close stmts need to be commented out to prevent the error msg.
' objDoc.Close SaveChanges:=True
' objDatatelDot.Close SaveChanges:=True


' Previous Code, which was the macro language from Word 95, still
supported for backward
' compatibility through the WordBasic object. Now replaced with equivalent
VBA.
'WordBasic.FileList 1
'WordBasic.FileOpen Name:="C:\DATATEL\DATATEL.DOC"
'WordBasic.MailMergeOpenDataSource Name:="C:\DATATEL\DATATEL.TXT",
ConfirmConversions:=0, ReadOnly:=0, LinkToSource:=1, AddToMru:=0,
PasswordDoc:="", PasswordDot:="", Revert:=0, WritePasswordDoc:="",
WritePasswordDot:="", Connection:="", SQLStatement:="", SQLStatement1:=""
'WordBasic.MailMerge CheckErrors:=1, Destination:=0, MergeRecords:=0,
From:="", To:="", Suppression:=0, MailMerge:=1, MailSubject:="",
MailAsAttachment:=0, MailAddress:=""

End Sub
 
D

Doug Robbins - Word MVP

What happens if you insert the following line of code before the
objDoc.MailMerge.Execute

MsgBox objDoc.MailMerge.DataSource.Name

Does it display the name of the expected data source?
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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