Thread: Printing issue
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Living the Dream Living the Dream is offline
external usenet poster
 
Posts: 151
Default 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.