473,414 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

ASP/MS Word - mail merging!

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
1 2048
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Morris | last post by:
Does anyone know whether it is possible to effect a mail merge to MSWord using VBScript in an asp file? I know it is possible to produce a doc file and force a download using ...
4
by: Tom Dauria | last post by:
I have an application that will be distributed remotely. In the Access application I am opening Word documents and mail merging. The Word documents are linked to a tmpLetter table. In my code I...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
1
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word...
1
by: jason301 | last post by:
I have started to get a problem when mail merging from my access database to word. When I mail merge the database password is requested to proceed which is odd as the database is already open. ...
1
by: David Costello | last post by:
Hi, I'm creating a program to do some mail merging, and I need to delete some white space that is before the text of the second page on my mail merging letter. Does anyone know a good way of...
6
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all...
7
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to follow a mail merging example in C#.Net that I got from: http://support.microsoft.com/default.aspx/kb/301659 and in one the methods: Word.Application wrdApp; Word._Document...
7
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.