Automate Word OLE32 merge printing with Ruby

D

Damjan Rems

What I would like to do is automate merge print documents without user
interference.

I have come so far:

fso = WIN32OLE.new("Scripting.FileSystemObject")
word = WIN32OLE.new('Word.Application')
path = fso.GetAbsolutePathName(ARGV.first)
doc = word.Documents.Open(path)
path = fso.GetAbsolutePathName('some.xls')
doc.MailMerge.OpenDataSource(path)


My questions:
At the line:
doc.MailMerge.OpenDataSource(path)
Words asks for choosing table (which is actualy a worksheet in excel
file). How can this be supresses or set automaticaly?

How to print all resulting documents?
Recorded macro says:
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 1
End With
.Execute Pause:=False
end


by
TheR
 

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

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top