OLE or Automation Print Excel From Access

G

Guest

I am able to print an excel.xls from Access using OLE or Automation. I have
the need to print the excel.xls to a smaller size page (i.e. from 11x17 to
letter size).

Here is my VBA Code to print an excel.xls:

Function printxls(filename As String)
Static xlApp As Variant
Static xlBook As Variant
Static xlSheet As Variant
Static path As String

Set xlApp = CreateObject("Excel.Application")
path = "c:\football\user reports\usc coverage chart\"

Set xlBook = xlApp.Workbooks.Open(path & filename & ".xls")
Set xlSheet = xlBook.Worksheets(1)
xlSheet.PrintOut
xlBook.Close (False)
xlApp.Quit

Set xlApp = Nothing
Set xlBook = Nothing
End Function


How can I change the paper size to letter and make it print to fit? These
commands are available on the drop down menu, but I want to do this in VBA
code in Access.


Thank You,

Gary
 
D

Douglas J Steele

Excel has the ability to record macros based on what you do with the mouse.
Use it to record what happens within Excel when you make that change, then
transfer that code to your routine in Access.
 

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