Opening a Word mailmerge Main Document (form letter)

C

Colin Halliday

I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge.

If I open this doc using the Word GUI, it first asks me to confirm that I want to run a query to select the data from the data source file, then it opens the form letter fine. I can preview the merged records and complete a merge to a new document.

I have a VB 2006 project (.net framework 2.0) which opens the same form letter in code like this:

aplWord.Documents.Open(mstrFormLetter)

This does open the form letter and displays it in Word, but it is no longer a mail merge main document. I have to manually link it to the data source before I can merge. Once I close the doc and open it manually in Word it is a main document still and asks me to confirm that I want to select the data from the data source again.

What else do I need to do in my code to open it ready for the mail merge??

Thanks.
 
C

Colin Halliday

BTW, it is not a VSTO project, just a normal Windows Form VB project.

Colin Halliday
 
C

Colin Halliday

Thanks, Doug.

Your reference to the KB Article answered my question.

My Word Application object had DisplayAlerts set to not display any alerts.
This stops Word from prompting about running the select statement on the
data source BUT ALSO STOPS THE DOC FROM BEING OPENED AS A MAILMERGE
DOCUMENT!

I have turned the alerts back on and it works fine.


Colin


Doug Robbins - Word MVP said:
Can't help with the dot net part, but for the SQL issue see the following
Knowledge Base article:

"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

Are you sure that the answer No was not given when the SQL message
appeared and the document was then saved. I believe that my convert it to
a normal Word document and hence detach it from the data source.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Colin Halliday said:
I have a Word 2003 mail merge main document (form letter) that is linked
to another Word document data source for the mail merge.

If I open this doc using the Word GUI, it first asks me to confirm that
I want to run a query to select the data from the data source file, then
it opens the form letter fine. I can preview the merged records and
complete a merge to a new document.

I have a VB 2006 project (.net framework 2.0 - not VSTO) which opens the
same form letter in code like this:

aplWord.Documents.Open(mstrFormLetter)

This does open the form letter and displays it in Word, but it is no
longer a mail merge main document. I have to manually link it to the
data source before I can merge. Once I close the doc and open it
manually in Word it is a main document still and asks me to confirm that
I want to select the data from the data source again.

What else do I need to do in my code to open it ready for the mail
merge??

Thanks.


I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge.

If I open this doc using the Word GUI, it first asks me to confirm that I want to run a query to select the data from the data source file, then it opens the form letter fine. I can preview the merged records and complete a merge to a new document.

I have a VB 2006 project (.net framework 2.0) which opens the same form letter in code like this:

aplWord.Documents.Open(mstrFormLetter)

This does open the form letter and displays it in Word, but it is no longer a mail merge main document. I have to manually link it to the data source before I can merge. Once I close the doc and open it manually in Word it is a main document still and asks me to confirm that I want to select the data from the data source again.

What else do I need to do in my code to open it ready for the mail merge??

Thanks.
 

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