Excel Automation

  • Thread starter Thread starter Joe Williams
  • Start date Start date
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)
 
Hi,
you can do like this:

oApp.Visible = False
Set xlW = oApp.workbooks.open(MYSPREADSHEET)
xlW.Printout
xlW.close
oApp.Quit
 
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
 
Back
Top