PrintOut Problem
You might need to revise the code to:
For Each sh In ActiveWorkbook.ActiveWindow.SelectedSheets
sh.PrintOut
Next
"MSuserATL" wrote:
Please HELP!
When I first call the code below in a macro from another spreadsheet, the
execution halts at the €˜SelectedSheets.PrintOut line. I have to close down
EXCEL using the Windows task manager. After I clear all instances of EXCEL
from the window task manager, the macros works. It successfully prints the
submitted spreadsheet as long as I continue to execute the macro within 20
minutes of the last execution.
Im certain that it halts at the €˜SelectedSheets.PrintOut line because when
I comment out the PrintOut line the macro runs through with no errors. Ive
also tried to catch the error at the €˜PrintOut line but the system never
throws one. Ive also tried to change the default printer but the same
results exist.
Sub print_48(fname As String)
' Disable the GUI Alerts
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.AskToUpdateLinks = False
Application.AlertBeforeOverwriting = False
Application.FeatureInstall = msoFeatureInstallNone
Workbooks.Open Filename:=fname, ReadOnly:=True
'Print Sheet
' this line causes an error
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.Close
End Sub
Your assistance will be greatly appreciated.
|