473,396 Members | 1,929 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,396 software developers and data experts.

mail merge to word

hello,

i am perfoming a mail merge with the following code.

Public Function MergeIt()
Dim objWord As Object
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the db3 database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Rapid Motion\Client " & _
"Info\Accident Claims UK\db3.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblsolicitordetails", _
SQLStatement:="SELECT * FROM [tblsolicitordetails]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

the first time i execute it, it fails because the word document does
not have the merge fields in place.

So i open the word document myMerge then set up the merge fields and
save it.

the second time i open it 2 instances of Word open, 1 with my merged
fields and all the merge options, and another that simply shows the
values of the merged fields and no merge options.

Why does this happen?

Aaron
Nov 13 '05 #1
2 3215

"Aaron" <aa***@rapid-motion.co.uk> wrote in message
news:26**************************@posting.google.c om...
hello,

i am perfoming a mail merge with the following code.

Public Function MergeIt()
Dim objWord As Object
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the db3 database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Rapid Motion\Client " & _
"Info\Accident Claims UK\db3.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblsolicitordetails", _
SQLStatement:="SELECT * FROM [tblsolicitordetails]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

the first time i execute it, it fails because the word document does
not have the merge fields in place.

So i open the word document myMerge then set up the merge fields and
save it.

the second time i open it 2 instances of Word open, 1 with my merged
fields and all the merge options, and another that simply shows the
values of the merged fields and no merge options.

Why does this happen?

Aaron
Your code includes a ' Execute the mail merge.
objWord.MailMerge.Execute


so the merge is executed and the output is made..

Where did you want it to go?
I think the default is to 'merge to a new document'
there is probably an argument for the others (printer or email) but having
not experiemented with these I can't help you with what they might be.

Mal.
Nov 13 '05 #2
Hum, I am going to suggest that you give my sample word merge a try. It
should work for you.

You can read the notes on how/why I fixed problems like the 2nd copy of
ms-access being launched, and also issues of security.

no need to re-invent the wheel here. Check out the word merge at:
http://www.attcanada.net/~kallal.msn.../msaccess.html
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #3

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

Similar topics

2
by: Steve M | last post by:
I'm trying to do invoke the mail merge functionality of MS Word from a Python script. The situation is that I have a template Word document, and a record that I've generated in Python, and I want...
2
by: William Wisnieski | last post by:
Hi Everyone, Access 2000 I have some code behind a button that performs a word merge with a query data source. The merge works fine. But what I'd like to do somehow is after the merge is...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
4
by: lesperancer | last post by:
I have 3 tables (office97) tblQuote quoteNbr tblDetails ( quote : 1 <-> M: quoteDetails) quoteNbr detailLine product value
8
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to...
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...
1
by: Esther Lane | last post by:
Hello! First off, many many thanks to Albert who wrote the Mail Merge code for MS Access I am using. It has been working beautifully for a few years. However, my client just (without notice!)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.