you can print an excel sheet from a command button in access what you have to do is add the Excel object library to your references and open excel as a new object and set a reference to the spreadsheet that you wish to print.
If you add the object library you will be able to use the object browser to view the classes and their members.
Hope this helps......i think i have an example if you need it.
This is what the code for my command button looks like but it falls over on the second line! any ideas???
Private Sub Command24_Click()
Dim exc As New Excel.Application
Dim objexc As Excel.Workbook
Dim objsheet As Excel.Worksheet
Set exc = CreateObject("Excel.Application")
Set objexc = exc.Workbooks.Open("N:\CUSTENQ\DATA\Confirmation\Alex Testing\Sales By Month Charts.xls")
Set objsheet = objexc.Sheets("Adam")
What is the second line? Second line of code, second executable line, what is the errormsg "falls over" doesn't give much to work on.
One guess though, have you set a reference to Excel? (in VBE Tools | References - set a checkmark on Microsoft Excel N Object Library - N being number according to the version)
Yes Sorted thanks! sorry did not mean the previous post as its sounded! i meant could you help me please. i would never try to put any one down with sarcastic posts! i really apreciate all the help i have been given.
Hi again Just another quick question if possible.
The sheet that i am printing out is as you say a pivot chart. (Sorry i should have mentioned that before) When this command button is pressed will the chart update itself with up to date data?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.