By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

ASP/MS Word - mail merging!

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Dan Nash" <da********@musoswire.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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")


Don't do that. See:
http://support.microsoft.com/?kbid=257757
http://support.microsoft.com/?kbid=270906

--
Tom Kaminski IIS MVP
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://mvp.support.microsoft.com/
http://www.microsoft.com/windowsserv...y/centers/iis/

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.