It could be the code is looking for the Sheet name:
e.g. Sheets("Name of Worksheet".PrintOut
ActiveSheet.PrintOut works for sure, however. If that still doesn't work for you, request the print preview option
ActiveSheet.PrintOut,,,True
to see if the preview is working. If it is, it might be a communication problem between your machine and the printer...not the code.
I can get it to print out now, but I cant get it to preview.
here is my sub I am using.
Dim x, Y, numFields As Integer
Dim j As Integer
Dim xlapp As Excel.Application
Dim xlwb As Excel.workbook
Dim sheet As Excel.Worksheet
Dim Db As DAO.Database
Dim rs1 As DAO.Recordset
Dim currentvalue As Variant
Dim currentfield As Variant
Dim workbook As Object
Set Db = CurrentDb()
Set rs1 = Db.OpenRecordset("8tranposed", dbOpenDynaset)
Set xlapp = New Excel.Application
Set xlwb = xlapp.Workbooks.Open("book1.xls"
Set sheet = xlapp.ActiveWorkbook.Sheets(1)
I do more code in here to load the data into the sheet.
then I try and print it.
xlwb.PrintOut _ this is working but I would like them to preview it
sheet.Application.ActiveWorkbook.Save
sheet.Application.ActiveWorkbook.Close
Set mysheet = Nothing
Set sheet = Nothing
Set xlapp = Nothing
Set Db = Nothing
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.