Results 1 to 3 of 3

Thread: Excel 97 - What the? Printpreview

  1. #1

    Thread Starter
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126

    Excel 97 - What the? Printpreview

    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.

    VB Code:
    1. Sub printsheet()
    2. Dim RngSelectedPrint As Range
    3. Set RngSelectedPrint = Worksheets(1).Range("A1:d20")
    4. RngSelectedPrint.PrintPreview 'enablechanges:=False
    5. Worksheets.PrintPreview enablechanges:=False
    6. End Sub

    VB Code:
    1. Sub printsheet2()
    2. Dim RngSelectedPrint As Range
    3. Set RngSelectedPrint = Worksheets(1).Range("A1:d20")
    4. RngSelectedPrint.PrintPreview enablechanges:=False
    5. Worksheets.PrintPreview enablechanges:=False
    6. 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.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    FWIW I use XL97 and can reproduce the fault.
    Regards
    BrianB
    -------------------------------

  3. #3

    Thread Starter
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    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.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width