Opening Word 2003 Merge documents with Automation

K

Kevin McBride

I'd previously posted this, but it has since rolled off the newsgroup, and
of course, I've forgotten what the solution was. Any help is greatly
appreciated...

I've run into a curious problem when automating a
document from Office 2003. I've tried this with VB6 and
VB.NET with the same result.

I have a mail merge document, with the data source saved,
and I open the document using something like:

Dim wrdApp as New Word.Application
wrdApp.Open(FileName:="MailMerge.Doc")
wrdApp.Visible = True

When the document is opened, it's opened as a Normal Word
Document, it's no longer a Mail Merge Letter. We use the
wrdDocument.MailMerge.State to return the document type,
and do special processing on Mail Merge docs.

Oddly, if I close Word, and open the document directly,
without automation, it opens as a MailMerge doc. This
only seems to happen with Office 2003, not with Office
2002 or 2000. Any idea's would be greatly appreciated!
 
J

Jerry

Try this instead, it worked for me:

Dim objWord As Word.Document
Set objWord = GetObject("<filename>", "Word.Document")
objWord.Application.Visible = True
objWord.Application.Activate

You must have a reference to word 11 objects in the vba.

Jerry
 
R

Rick

I think I have your answer. I was also having a problem very similar to yours. I was opening a mailmerge doc from within access and it would not merge. What seems to happen is that an information dialog appears reminding you about the sql statement that will open your merge. I have found a registry key you need to add that will disable that information box, which in turn will keep your document a mail merge instead of a normal document (kbinfo KB825765) It worked for me I think it will work for you as well

----- Kevin McBride wrote: ----

I'd previously posted this, but it has since rolled off the newsgroup, an
of course, I've forgotten what the solution was. Any help is greatl
appreciated..

I've run into a curious problem when automating
document from Office 2003. I've tried this with VB6 an
VB.NET with the same result

I have a mail merge document, with the data source saved
and I open the document using something like

Dim wrdApp as New Word.Applicatio
wrdApp.Open(FileName:="MailMerge.Doc"
wrdApp.Visible = Tru

When the document is opened, it's opened as a Normal Wor
Document, it's no longer a Mail Merge Letter. We use th
wrdDocument.MailMerge.State to return the document type
and do special processing on Mail Merge docs

Oddly, if I close Word, and open the document directly
without automation, it opens as a MailMerge doc. Thi
only seems to happen with Office 2003, not with Offic
2002 or 2000. Any idea's would be greatly appreciated
 
D

dixie

I am having a very similar problem and unfortunately, I too have not seen
the previous messages. I am in the position of having an Access 2000
database that sends out a data text file and then automates by opening a
mailmerge template where the text file is the source. It is now giving
messages indicating that the document is not a mailmerge main document. If
anyone has a workaround, I really need to find out quickly as this is in an
applciation that is running on A2k, AXP and just now, A2003. It is sending
me around the twist as I don't have 2003 to fiddle with as I develop in
2000.

dixie
Rick said:
I think I have your answer. I was also having a problem very similar to
yours. I was opening a mailmerge doc from within access and it would not
merge. What seems to happen is that an information dialog appears reminding
you about the sql statement that will open your merge. I have found a
registry key you need to add that will disable that information box, which
in turn will keep your document a mail merge instead of a normal document
(kbinfo KB825765) It worked for me I think it will work for you as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top