PDA

Click to See Complete Forum and Search --> : Excel 97 - What the? Printpreview


TheFIDDLER
Apr 5th, 2004, 07:31 PM
Sorry about posting this again, but I just stumbled on the weirdest thing. Can anyone explain to me the difference between these two subroutines? Or why the first one works and the second one doesn't.


Sub printsheet()
Dim RngSelectedPrint As Range
Set RngSelectedPrint = Worksheets(1).Range("A1:d20")
RngSelectedPrint.PrintPreview 'enablechanges:=False
Worksheets.PrintPreview enablechanges:=False
End Sub



Sub printsheet2()
Dim RngSelectedPrint As Range
Set RngSelectedPrint = Worksheets(1).Range("A1:d20")
RngSelectedPrint.PrintPreview enablechanges:=False
Worksheets.PrintPreview enablechanges:=False
End Sub


"print preview method of range class failed" ? what the?
At first I thought this was an error caused the version of Excel I was in. Turned out to be a coding issue.

And yes - I know I have two back to back print preview statements. It's to show the diff between accessing from a worksheet and a defined range.

BrianB
Apr 6th, 2004, 04:03 AM
FWIW I use XL97 and can reproduce the fault.

TheFIDDLER
Apr 6th, 2004, 08:59 PM
I tried it on three machines, using XL97 and XP and got the same error result.

It is a result of the following code:
RngSelectedPrint.PrintPreview enablechanges:=False
which works, if you omit the enable changes parameter.

Using the worksheet as the object, the parameter works fine,
Worksheets.PrintPreview enablechanges:=False

Still would like to know if anyone else but me is getting this same result, and what a work-around or fix could be. I want to gain access to the enable changes parameter, but I also need to specify a certain range area, not the total worksheet.