Hi guys
I wonder if you could help. I'm trying to create a bespoke interface for
mail merging from an Access database in Word. At the moment, I'm just trying
it with CSV files, and it works. Word loads, data gets pasted in and it
merges fine. One problem tho, it's doing Form Letters rather than Mailing
Labels
Here's the code...
set app = createobject("Word.Application")
app.Application.Visible = True
set oMainDoc = app.Documents.Add()
oMainDoc.mailmerge.MainDocumentType = wdFormLetters
oMainDoc.mailmerge.OpenDataSource
"C:\Inetpub\wwwroot\darts\data\mergedata\testdata. csv" ', False, False,
True, False, "", "", "", "", False, wdOpenFormatAuto, "", "", ""
With oMainDoc.MailMerge
With .Fields
Set oSel = App.Selection
.Add oSel.Range, "Name"
oSel.TypeParagraph
Set oSel = App.Selection
.Add oSel.Range, "Address"
oSel.TypeParagraph
End With
oMainDoc.mailmerge.Execute False
End With
With oMainDoc
.MailMerge.Destination = wdSendToNewDocument
.MailMerge.Execute False
End With
Ok, I've tried setting the MainDocumentType variable to wdMailingLabels, but
to no avail. There's probably some other settings I need to create Mailing
Labels, however.. when I go into Mail Merge setup in Word, it still shows
Form Letters, no matter what I set MainDocumentType to, and it still merges
to form letters too.
Any ideas why/what I've got wrong? Everything else seems to work. Help
greatly appreciated!
Cheers
Dan