+ Reply to Thread
Results 1 to 3 of 3

close print preview - vba escape code

  1. #1
    Registered User
    Join Date
    03-20-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Smile close print preview - vba escape code

    hi

    got stuck on this one - macro is not exiting from print preview mode

    please help me if you know the VBA code so it can close the print preview mode (preferably not "private sub" code)


    thanks in advance
    Last edited by yeoye; 03-24-2009 at 06:13 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: close print preview - vba escape code

    I don't know if you can. Print Preview is modal -- code suspends until you close it.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-20-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Smile Re: close print preview - vba escape code

    ok, the answer seems very simple

    as the code was written via using record macro command as suppose to writing code in vba module directly, when the macro is run, by default it stops at print preview screen without closing the screen due to this code:
    ActiveWindow.SelectedSheets.PrintPreview

    I had to disable this code by putting an apostrophe in front of it and disable it

    to make it look like this:
    'ActiveWindow.SelectedSheets.PrintPreview

    In other words macro runs as usual, adjusting required margins etc, and skips print preview mode.

    The final code is given below for those who want to adjust print margins, landscape print setup, insert footer and other options in print preview mode but without actually being stuck on print preview screen, halting the macro continuing executing rest of the code.



    Please Login or Register  to view this content.



    I was very surprised not finding any suitable material in all excel related forums I could find in google over the past 2 days
    Last edited by dominicb; 03-24-2009 at 07:06 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1