merge error 5535

C

Curt

Have the following code works great when print canceled. Now when you check 1
in print dialog screen. It merges all records. but before it does it displays
error 5535 could not finish mergeing or inserting database. debug came up on
..Execute Pause cannot remove or no merge.
Can anyone see what I can't Stumped at this point.
Thanks
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
'.Destination = wdSendToPrinter
With Dialogs(wdDialogFilePrint)
If .Show <> -1 Then
Application.Quit SaveChanges:=wdDoNotSaveChanges
Exit Sub
'ActiveDocument.PrintOut Background:=False
' ActiveDocument.Close wdDoNotSaveChanges
' Application.Quit SaveChanges:=wdDoNotSaveChanges
' Exit Sub
'Application.Quit SaveChanges:=wdDoNotSaveChanges
End If
End With
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub
 
D

Doug Robbins - Word MVP

Try

With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With
With Dialogs(wdDialogFilePrint)
If .Show <> -1 Then
Application.Quit SaveChanges:=wdDoNotSaveChanges
Exit Sub
End If
End With

It may be better not to include the

Application.Quit SaveChanges:=wdDoNotSaveChanges

so that the user has a second chance.
--
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
 
C

Curt

used Application quit so it returns to program printer choice userform. What
I don't get is why it gives error mess then completes merge fine. Move code
as per your suggestion no sucess darn it. if I take out app quit I return to
the word.doc I open for the merge. then you have to close it. Maybe there is
a better way to get it closed?
Thanks
 
C

Curt

stilltrying to get this copied code now it does merge then error 5535 and
hangs on .execute from debug
Stuck Thanks
 
D

Doug Robbins - Word MVP

If you use just

With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With

Does it execute the merge without problem, leaving the result of the merge
as the active document?

Then, can you tell us what you want to be done:

(a) If in the File Print dialog, the user pressed OK?

(i) The active document will be printed and closed? - Yes or No?

(ii) The mail merge main document will be closed? - Yes or No?

(b) If in the File Print dialog, the user presses Cancel?

(i) The active document will be closed? - Yes or No?

(ii) The mail merge main document will be closed? - Yes or No?

--
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
 
C

Curt

no I still get error message however after going to debug the merged document
is there
tested added send to printer under document if you cancel print error 4198
debug .execute close goes back to doc for merge. start over error 5535 then
prints merged doc then back to error 5535 debug back to execute.
Wondering if I have a corruped file in word. I will run my disc to see if
repair helps on install Sure gets puzzling
Thanks much
 
C

Curt

used the following cancel works fine however it does not do the merge comes
up with 4198 ???
I am stumped
Thanks
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Destination = wdSendToPrinter
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
With Dialogs(wdDialogFilePrint)
If .Show <> -1 Then
Application.Quit SaveChanges:=wdDoNotSaveChanges
Exit Sub
End If
End With
..Execute
Application.Quit SaveChanges:=wdDoNotSaveChanges
' .Execute Pause:=True
'.
End With
'

End Sub
 
D

Doug Robbins - Word MVP

Use the following:

Dim MMMainDoc as Document, NewDoc as Document
Set MMMainDoc = ActiveDocument 'The mail merge main document
With MMMainDoc.MailMerge
.Destination = wdSendToNewDocument
.Execute
' the balance of the commands are superfluous
End With
Set NewDoc = ActiveDocument
With Dialogs(wdDialogFilePrint)
If .Show <> -1 Then
NewDoc.Close wdDoNotSaveChanges
Else
NewDoc.Close wdDoNotSaveChanges
End If
End With
'If you want to also close the mail merge main document, include the
following command
MMMainDoc.Close

--
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
 
C

Curt

Progress
Brought up the merged doc
Error message 5535
debug yellow on .execute
close vba debug
returned to merged doc.
(the merge doc is complete then the error message apears on top)
 
D

Doug Robbins - Word MVP

I think that you may have some sort of problem with the data source. Does
the data from all of the records appear in the result?

--
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
 
C

Curt

yes when I look at the merged doc all data is there. form letters1 close it
get doc I used to set up merge with macro in. close it then I return to the
userform I started from
This is a bummer
Thanks
 
C

Curt

Found that if I remove the Query string It shows all records but I need to
have query to stop as all records are not filled. Query string for some
reason only allows * records. Will look closer at data.
Thanks
 
C

Curt

sucess problem was with query string changed it to only 1 field an works
Thanks for your patience
 
C

Curt

A little better explanation of error problem One field meet criteria others
did not. It seems word gets into problem if one field is go and rest arn't
Hope this helps someone else.
Thanks for your assistance
 

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