473,612 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MailMerge

I have a Word(2000) mailmerge routine (code below) which works OK but always
names the merged document "Forml Letters1". How do I change this to
something else?

Also how do I automatically save the merged document to a specific
destination?

Dim wrdApp As Word.Applicatio n

Dim wrdDoc As Word._Document

Private Sub Button1_Click(B yVal sender As System.Object, _

ByVal e As System.EventArg s) Handles Button1.Click

Dim wrdSelection As Word.Selection

Dim wrdMailMerge As Word.MailMerge

Dim wrdMergeFields As Word.MailMergeF ields

' Create an instance of Word

wrdApp = CreateObject("W ord.Application ")

' Open template document.

wrdDoc = wrdApp.Document s.Open("c:\anni e\letrbase.doc" )

wrdDoc.Select()

wrdSelection = wrdApp.Selectio n()

wrdMailMerge = wrdDoc.MailMerg e()

' Open MailMerge Data file.

wrdDoc.MailMerg e.OpenDataSourc e("C:\annie\let rdata.txt")

' Perform mail merge.

wrdMailMerge.De stination = _

Word.WdMailMerg eDestination.wd SendToNewDocume nt

wrdMailMerge.Ex ecute(False)

' Make merged Doc visible.

wrdApp.Visible = True

' Close the original form document.

wrdDoc.Saved = True

wrdDoc.Close(Fa lse)

' Release References.

wrdSelection = Nothing

wrdMailMerge = Nothing

'wrdMergeFields = Nothing

wrdDoc = Nothing

wrdApp = Nothing

End Sub
Nov 20 '05 #1
0 1395

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1289
by: Bud Zielinski | last post by:
Some of our users have converted to Office 2003. Our Access app is in 2000. they run it in Access 2003 with Access 2000 as the default file format. When doing a merge from the partial code segment below, we had rec'd the : "Opening this will run the following SQL Command" message. We were able to suppress that message with registry changes and code contained in MSKB 82765.
1
353
by: Bud Zielinski | last post by:
Some of our users have converted to Office 2003. Our Access app is in 2000. they run it in Access 2003 with Access 2000 as the default file format. When doing a merge from the partial code segment below, we had rec'd the : "Opening this will run the following SQL Command" message. We were able to suppress that message with registry changes and code contained in MSKB 82765.
1
1889
by: Nicolae Fieraru | last post by:
Hi All, I made an access Application which uses mailmerge function. I have a query which I use to mailmerge to a word document. I created the word document as a new document and I saved onto the computer. Then, I have a form with a button which runs the query and opens the word document The code which is linked to the button is:
2
1912
by: Shannon Rotz | last post by:
I have a function in a Microsoft Access module (below) which creates a Word XP Mailmerge document, drawing the data from Access XP. I can get the connection to work fine. However, when I create the form letters, the data from certain merge fields is missing. When I view the data in the MailMerge Recipients dialog box, the data is not there either - the columns are there, but the records have blanks where the data in those columns should...
4
12045
by: Ray Todd Jr | last post by:
I can't get ths code to correctly execute. After I have clicked on a Access Form, I want the code to open the word document, merge the data, print the forms and then close the two windows that open of Word. The Mail Merge takes place, and the sticking point is that I have to manually close the two Word Windows. Can someone please tell me what I'm not doing correctly. Below is the code I am using...
0
1078
by: RH | last post by:
Hi, I'm trying to use mailmerge with Word2003 from an asp.net webpage I'm using the following code: Dim W As New Word.Application Dim D As Word.Document = W.Documents.Open("maindoc.doc") D.MailMerge.OpenDataSource("address.txt") D.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument D.MailMerge.Execute()
2
13502
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to execute a MailMerge to create mailing labels or customized letters. A label name known to MS Word MailMerge mailing label wizard may be used or a template file containing the field names Line1 thru Line5 for each record to be printed. If a...
0
1606
by: Bob Smith | last post by:
I have existing word documents that we need to have the data document reflect whether we're running in development, test or production. The data header is longer than 255 characters, so I cannot put the structure in either createdatasource or opendatasource so I have to build it on the fly. The code I have written is as follows:
0
1282
by: bobh | last post by:
Hi All, I have this older code(see below) that I used for a mailmerge in another application, I'm looking to do something similar but a little different in that, this time I have a single record to merge and after the merge to the document I want to store it on a particular server in a particular folder with a particular file name and I don't know what the coding would be for that. I assume it would go in place of the...
0
8173
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8115
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8568
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8422
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6082
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5537
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4111
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2555
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1699
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.