Excel Automation

J

Joe Williams

I have the following code which opens an excel file with a file name from a
combo box on a form. Instead of opening the file, I would just like the
entire workbook to be printed without opening the file. How can I change the
code to accomplish this? Thanks

Dim oApp As Object
Dim MYSPREADSHEET As String
Dim xlW As Object, xlApp As Object
MYSPREADSHEET = "\\g:\quality\qa\Control Plans - Molding\" & Me.cboPart
& ".xls"
MsgBox MYSPREADSHEET
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
Set xlW = oApp.workbooks.open(MYSPREADSHEET)
 
A

Alex Dybenko

Hi,
you can do like this:

oApp.Visible = False
Set xlW = oApp.workbooks.open(MYSPREADSHEET)
xlW.Printout
xlW.close
oApp.Quit
 
J

Joe Williams

Alex,

Works great! Thank you!

Joe


Alex Dybenko said:
Hi,
you can do like this:

oApp.Visible = False
Set xlW = oApp.workbooks.open(MYSPREADSHEET)
xlW.Printout
xlW.close
oApp.Quit
 

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