Send Print or Print Preview Command to Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a command button that when pushed dumps data into MS Excel. Does
anyone know how I can have this automatically print out the sheet?
 
James:

The Workbook, Worksheet, and Range objects in Excel all have a PrintOut
method as well as a PrintPreview method. For example:

Function PrintWorksheet()
Dim xl As New Excel.Application
Dim wkb As Excel.Workbook

Set wkb = xl.Workbooks.Open("C:\TestBase.xls")

wkb.Sheets(1).PrintOut

wkb.Close
xl.Quit

Set wkb = Nothing
Set xl = Nothing

End Function

You will need a reference to the Excel Object Library, of course.


--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I have a command button that when pushed dumps data into MS Excel. Does
anyone know how I can have this automatically print out the sheet?
 
Back
Top