You set a reference to the workbook and then didn't use it.
Power point doesn't know what "WorkSheets" is and the
Excel application is not visible when it starts, so there is no ActiveWorkbook.
Also, you have duplicated your exit routine.
Try...
'print routine
Sub PrintAtt(fFullPath As String)
On Error GoTo ErrorHandler
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
' in the background, create an instance of xl then open, print, quit
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open(fFullPath)
wb.Worksheets("(1)ORDER FORM").PrintOut
ExitSubHe
wb.Close savechanges:=False
Set wb = Nothing
xlApp.Quit
Set xlApp = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error Code: " & Err.Number & vbCrLf & _
"Description: " & Err.Description
Err.Clear
GoTo ExitSubHere
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.contextures.com/excel-sort-addin.html
(30+ ways to sort in excel)
..
..
..
"J"
wrote in message
...
Hi everyone-
I'm trying to use VBA to print a specific "(1)ORDER FORM" worksheet
from workbooks that I'm receiving in Outlook. I've constructed the
following, but it keeps erring out when reaches the
Worksheet("(1)ORDER FORM").Printout line. I receive errors ranging
from error 9 to error 462 to error 1004. What am I doing wrong? Thanks
for your help in advance!
-snip-
'print routine
Sub PrintAtt(fFullPath As String)
On Error GoTo ErrorHandler
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
'in the background, create an instance of xl then open, print, quit
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open(fFullPath)
Worksheets("(1)ORDER FORM").PrintOut
ActiveWorkbook.Close savechanges:=False
Set wb = Nothing
xlApp.Quit
Set xlApp = Nothing
ExitSub:
ActiveWorkbook.Close savechanges:=False
Set wb = Nothing
xlApp.Quit
Set xlApp = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error Code: " & Err.Number & vbCrLf & _
"Description: " & Err.Description
Err.Clear
GoTo ExitSub
End Sub