Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Printing Issue | Excel Discussion (Misc queries) | |||
Printing issue | Excel Discussion (Misc queries) | |||
Help with Printing Issue | Excel Discussion (Misc queries) | |||
printing issue | Excel Programming | |||
Printing issue | Excel Discussion (Misc queries) |