Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print Preview (97:SR2)

    I am having difficulty closing a widow opened with: ActiveWindow.SelectedSheets.PrintPreview

    I have tried using SendKeys to actually send the letter C to close the window. MSHelp suggests enclosing the letter C in quotes ie "C" but this only enters the letter C into the workbook.

    Any suggestions would be appreciated.
    Thanks,
    John

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Print Preview (97:SR2)

    I think once you call "Printpreview", the macro waits until the "dialog" is closed before proceeding.

    The user must close it down (eg the user can hit the "C" key, click the <close> button or press the <esc> key) when they are done viewing it, then the macro will proceed.

    It is comparable to Userforms and other dialogs in XL97: once they are open, the macro stops and does not continue until they are closed.

    Sendkeys should have the C in quotes ("C") unless you are "sending" a keystroke that is stored in a variable named C.

    (I assume you do not have "Option Explicit" or the line
    Sendkeys C
    would give a "compile error" when you run the macro, since the variable c is not defined)

    Steve

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Preview (97:SR2)

    Do you actually need to open Print Preview with your code? Most of your Setup operations in code can be done with Page Break Preview or Page Setup.
    Gre

Posting Permissions

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