View Single Post
  #3   Report Post  
Posted to microsoft.public.dotnet.languages.vb,microsoft.public.word.mailmerge.fields
Chubbly Geezer
 
Posts: n/a
Default Mailmerge Automation Problems

Hi Cindy

Had come round to the fact of using OpenDataSource. Just trying that now,
but unsure what the 'Name' parameter should hold.

I am using VB 2005, Word 2003 and trying to pull in data from an SQL 2005
table.

--------------------------------------
Dim wrdMailMerge As Word.MailMerge

Dim wrdMergeFields As Word.MailMergeFields

Dim wrdSelection As Word.Selection

wrdApp = CreateObject("Word.Application")

wrdApp.Visible = True

wrdDoc =
wrdApp.Documents.Open("C:\temp\2005\WordDocument1\ WordDocument1\DeliveryAddress.doc")

wrdDoc.MailMerge.OpenDataSource(Name:="Name", ConfirmConversions:=False,
ReadOnly:=True, LinkToSource:=True, AddToRecentFiles:=False,
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=True,
Format:=Word.WdOpenFormat.wdOpenFormatAuto, Connection:="data source=WEBDEV;
initial catalog=Subscriptions2; integrated security=SSPI; persist security
info=False; packet size=4096; Connect Timeout=300", SQLStatement:="select *
from subscriptionsprintqueue", SQLStatement1:="",
SubType:=Word.WdMergeSubType.wdMergeSubTypeOther)

wrdDoc.MailMerge.Execute()

--------------------------------------


Many thanks

Chubbly


"Cindy M -WordMVP-" wrote in message
news:VA.0000bee5.00a5e089@speedy...
Hi Chubbly,

Hope you can help. I have created a mail merge word doc which seems to
work
fine. When I close and reload it asks if I wish to pull in the data.
Great.

However, I want to print the results of the mail merge from within a
VB.Net
app. I can create and load the word app/doc, but the document is not
opened
as a mail merge doc. In fact the mail merge fields just appear as text.

It would help if you'd show us the code you're using... You also need to
tell
us which version of Word you're testing on, which versions are targeted,
what
type of data source is involved and, if you know, which connection method
is
being used.

My best guess would be you're running into this:
"Opening This Will Run the Following SQL Command" Message When You Open a
Word
Document - 825765
http://support.microsoft.com?kbid=825765

In an automation environment, where this security measure is activated,
you
MUST use the OpenDataSource method to connect the data after the document
is
opened. The data source is unlinked without question when a mail merge
document
is opened by automation.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply
in the newsgroup and not by e-mail :-)