![]() |
Printing issue
Hi everyone.
Even though the company has upgraded to 2007 recently, up until this week, this code has been used to great success. Now it throws up the following error: Run-time error ‘1004’: Method ‘Range’ of Object’_Worksheet’ Failed. Any thoughts or suggestions as to why all of a sudden it is halting at this point: .................................................. ....................... If Set_PageSetup(myWkS, myWkS.Range("LHdrText")) Then myWkS.PrintOut Preview:=True Else MsgBox "An error occured doing PageSetup for sheet '" _ & myWkS.Name & "'!" .................................................. ...................... THE FULL CODE: Function Set_PageSetup(Target As Worksheet, LHdrText As String) As Boolean myDate = Format(Date, "Ddd, dd-Mmm-yy") On Error GoTo ErrExit With Target.PageSetup .PrintArea = Selection.Address .PrintTitleRows = "$1:$1" .LeftHeader = LHdrText .RightHeader = myDate .FitToPagesWide = 1 End With ErrExit: Set_PageSetup = (Err = 0) If Not Set_PageSetup Then wks.CenterHeader = "": wks.PrintArea = "" End Function Sub PrintHDCReports() Dim myWkS As Worksheet Set myWkS = ActiveSheet Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select If Set_PageSetup(myWkS, myWkS.Range("LHdrText")) Then myWkS.PrintOut Preview:=True Else MsgBox "An error occured doing PageSetup for sheet '" _ & myWkS.Name & "'!" End If End Sub Appreciate any thoughts and assistance TIA Mick. |
Printing issue
On Monday, October 29, 2012 5:46:32 AM UTC-5, Living the Dream wrote:
Hi everyone. Even though the company has upgraded to 2007 recently, up until this week, this code has been used to great success. Now it throws up the following error: Run-time error �1004�: Method �Range� of Object�_Worksheet� Failed. Any thoughts or suggestions as to why all of a sudden it is halting at this point: .................................................. ...................... If Set_PageSetup(myWkS, myWkS.Range("LHdrText")) Then myWkS.PrintOut Preview:=True Else MsgBox "An error occured doing PageSetup for sheet '" _ & myWkS.Name & "'!" .................................................. ..................... THE FULL CODE: Function Set_PageSetup(Target As Worksheet, LHdrText As String) As Boolean myDate = Format(Date, "Ddd, dd-Mmm-yy") On Error GoTo ErrExit With Target.PageSetup .PrintArea = Selection.Address .PrintTitleRows = "$1:$1" .LeftHeader = LHdrText .RightHeader = myDate .FitToPagesWide = 1 End With ErrExit: Set_PageSetup = (Err = 0) If Not Set_PageSetup Then wks.CenterHeader = "": wks.PrintArea = "" End Function Sub PrintHDCReports() Dim myWkS As Worksheet Set myWkS = ActiveSheet Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select If Set_PageSetup(myWkS, myWkS.Range("LHdrText")) Then myWkS.PrintOut Preview:=True Else MsgBox "An error occured doing PageSetup for sheet '" _ & myWkS.Name & "'!" End If End Sub Appreciate any thoughts and assistance TIA Mick. Don't see how this workedd myWkS.PrintOut Preview:=True maybe myWkS.preview:=True what are you trying to do. If desired, send file to dguillett @gmail.com |
All times are GMT +1. The time now is 02:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com