R
Ron Ford
I am trying to send a merge document to the printer from
the command line and would like to suppress (or
automatically answer) Word dialog questions so the entire
process can occur without user intervention. The
datasource, test.txt, contains a single record.
Using Word 2002 on XP Professional.
My command line is:
\(path_to_word)\winword docfile.dot /mMyMerge
the Word macro is:
Sub MyMerge()
With Active.Document.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord =
ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord =
ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
SendKeys "%N" 'To answer the 'Save' document question.
End With
ActiveDocument.Close
Application.Quit
End With
End Sub
The SendKeys successfully prevents the save document
dialog from appearing, but I haven't been able to prevent
an earlier dialog which states:
Opening this document will run the following SQL command:
SELECT * FROM c:\testdir\test.txt
Data from your database will be placed in the document.
Do you want to continue?
Yes No
Since I always want the Yes option, I've tried adding
SendKeys "%Y" to every line in the macro without effect.
Is there another method of suppressing this dialog?
Many thanks.
the command line and would like to suppress (or
automatically answer) Word dialog questions so the entire
process can occur without user intervention. The
datasource, test.txt, contains a single record.
Using Word 2002 on XP Professional.
My command line is:
\(path_to_word)\winword docfile.dot /mMyMerge
the Word macro is:
Sub MyMerge()
With Active.Document.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord =
ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord =
ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
SendKeys "%N" 'To answer the 'Save' document question.
End With
ActiveDocument.Close
Application.Quit
End With
End Sub
The SendKeys successfully prevents the save document
dialog from appearing, but I haven't been able to prevent
an earlier dialog which states:
Opening this document will run the following SQL command:
SELECT * FROM c:\testdir\test.txt
Data from your database will be placed in the document.
Do you want to continue?
Yes No
Since I always want the Yes option, I've tried adding
SendKeys "%Y" to every line in the macro without effect.
Is there another method of suppressing this dialog?
Many thanks.