Word 2000 and mailmerge macro code

S

Samuel Tribehou

(First posted to microsoft.public.word.mailmerge.fields, but received no response. So here i am...)

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
 

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