Trying to automate the mail merge function to get values from an excel document into a word document, I've googled quite a bit, but can't seem to find the last two pieces of the puzzle. One the script is prompting me to select the table (there's only one sheet in the workbook) and two, how do I get word to wait until printing is complete before closing. The code I have so far is below
Set objWord = CreateObject("Word.Application")
objword.Documents.Open("c:\mail merge test\Test.doc")
objword.ActiveDocument.MailMerge.OpenDataSource("c:\mail merge test\Test.xls")
objword.ActiveDocument.MailMerge.Execute()
objword.ActiveDocument.PrintOut
'I sleep so that the documents will print
WScript.Sleep 10000
objword.Quit(0)
Any help would be greatly appreciated.
Set objWord = CreateObject("Word.Application")
objword.Documents.Open("c:\mail merge test\Test.doc")
objword.ActiveDocument.MailMerge.OpenDataSource("c:\mail merge test\Test.xls")
objword.ActiveDocument.MailMerge.Execute()
objword.ActiveDocument.PrintOut
'I sleep so that the documents will print
WScript.Sleep 10000
objword.Quit(0)
Any help would be greatly appreciated.