error 4605 on mailmerge labels macro

S

Samuel Tribehou

Hello,

I have a problem with Word 2000 when i try to create a macro to execute
mailmerge labels.
Word complains with error 4605 ( translation from french : the document does not
contains any fields to merge),
and this is triggered by the ActiveDocument.MailMerge.Execute method.
I did follow Q209812 (Mail Merge Macro Fails to Record Label Number), which
involves inserting the
Name argument of Application.MailingLabel.CreateNewDocument by hand since word
doesn't records it.
But it didn't solve the problem...

Any ideas ?
(I am not sure what number I should use as the Name argument, i just followed
the KB example.
If i understood correctly, it represents the type of mailmerge. Could it be my
problem ?)



Sub AutoOpen()

Dim file
With Dialogs(wdDialogFileOpen)
If .Display = -1 Then
file = CurDir & "\" & .Name
End If
End With

ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels
Application.MailingLabel.DefaultPrintBarCode = False
Application.MailingLabel.CreateNewDocument Name:="5160", Address:= _
"«elev_civi_nom»«elev_civi_prenom»" & Chr(13), AutoText:="", LaserTray:=
_
wdPrinterManualFeed
ActiveDocument.MailMerge.OpenDataSource Name:= _
file _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="", SQLStatement:="",
SQLStatement1 _
:=""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
End Sub
 
S

Samuel Tribehou

Same post with unbreaked lines to make it easier to read (i hope...) :


Hello,

I have a problem with Word 2000 when i try to create a macro to execute mailmerge labels.
Word complains with error 4605 ( translation from french : the document does not contains any fields to
merge),
and this is triggered by the ActiveDocument.MailMerge.Execute method.
I did follow Q209812 (Mail Merge Macro Fails to Record Label Number), which involves inserting the
Name argument of Application.MailingLabel.CreateNewDocument by hand since word doesn't records it.
But it didn't solve the problem...

Any ideas ?
(I am not sure what number I should use as the Name argument, i just followed
the KB example.If i understood correctly, it represents the type of mailmerge. Could it be my problem ?)



Sub AutoOpen()

Dim file
With Dialogs(wdDialogFileOpen)
If .Display = -1 Then
file = CurDir & "\" & .Name
End If
End With

ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels
Application.MailingLabel.DefaultPrintBarCode = False
Application.MailingLabel.CreateNewDocument Name:="5160", Address:= _
"«elev_civi_nom»«elev_civi_prenom»" & Chr(13), AutoText:="", LaserTray:= _
wdPrinterManualFeed
ActiveDocument.MailMerge.OpenDataSource Name:= _
file _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="", SQLStatement:="", SQLStatement1 _
:=""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
End Sub
 
Top