How do I reference a particular spreadsheet programatically?

M

Matthew Speed

My code:

filetoopen = Environ("homedrive") & Environ("homepath") &
"\Desktop\qryContractMerge.xls"
Set mymerge = ActiveDocument.MailMerge
With mymerge
.Destination = wdSendToPrinter
.OpenDataSource Name:=filetoopen
.Execute
End With
Application.Quit savechanges:=wdDoNotSaveChanges

When I do this it asks me which table to use, qryContractMerge.xls or
qryContractMerge or qryContractMerge$

How do I tell it which table to use in code instead of having to
select it?
 

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

merge error 5535 14
print cancel 1
How to suppress Word dialogs during merge 1
AppleScript - How do I select a text ? 1
control print 2
macro 2 issues 0
macro stops 0
Macro won't print under XP...? 5

Top