Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Issue Krazy4mytt Excel Discussion (Misc queries) 0 December 16th 08 03:18 PM
Printing issue Sheryl[_2_] Excel Discussion (Misc queries) 1 April 10th 07 09:52 AM
Help with Printing Issue Playa Excel Discussion (Misc queries) 0 October 27th 06 07:31 PM
printing issue neilwebb[_3_] Excel Programming 1 July 11th 05 01:45 PM
Printing issue [email protected] Excel Discussion (Misc queries) 2 June 24th 05 08:21 AM


All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"