+ Reply to Thread
Results 1 to 1 of 1

PrintPreview won't come take focus after being launched by VBA Macro

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    PrintPreview won't come take focus after being launched by VBA Macro

    This is in Excel 2010 on both Win7 and WinXP.

    I have a rather extensive macro for formatting a dozen sheets for printing. This involves hiding some columns, setting print ranges, and setting some page setup options. The whole macro takes about 2.5 minutes to run (that's a bit crazy but I'm not so worried about that).

    The problem I'm having is at the very end. It opens Print Preview using
    Please Login or Register  to view this content.
    - AllSheetsPrint is an array that includes the names of all the sheets I want to print. It works fine, except that the Print Preview button doesn't seem to be able to gain focus on its own. It may come to the foreground, but as often as not, the buttons are disabled - the print button as well as the close button. When the buttons are disabled, [x]ing out often works, to close Print Preview, but that doesn't help someone print. Minimizing the window and restoring it seems to fix it.

    I am wanting to know if there is something I can do to make it NOT need to be minimized & restored for the buttons to work?

    I spent most of this afternoon trying to research this, and found plenty of suggestions for hiding a user form that was used to initiate the opening of the PrintPreview window, but nothing for it being a bit of VBA that gets run from the actual excel sheet.

    Attached is a rather stripped down version of my actual excel file. I can't recreate the issue in this file, so I'm thinking maybe it has something to do with how many sheets are in the real file. The real file has 13 sheets that need to be printed.

    The password to unlock sheets is "abc" - I don't have a password on the vba (probably obviously, this, as well as the content of the file, is tweaked to avoid posting potentially confidential information)

    The print macro is executed by end users by clicking the blue "Print the entire CBA" button on the Table of Contents sheet. This calls a macro called PrintAll in the module PrintCBA. It reads the print ranges and a few other options from a sheet called "Print Ranges". Error handling is disabled for now, but no errors are popping up.

    Just to clarify - I was NOT able to recreate the issue in the excel file I'm posting, but the code in it is the same code in my production file. The example file just has a fraction of the number of sheets - the production version is about 5.5 MB.

    I'm really guessing that this is either an Excel limitation, or it is related to my file being so unbearably huge.

    The goal is to display Print Preview so that the user will be in a position to set their own print options - select a printer, choose how many copies, set whether to do grey scale or color, etc. The goal is also to have good print ranges defined, which means having a number of hidden columns (columns that don't need to be printed and take up valuable real-estate on the page)

    Is there anything I can do?

    Thanks!!
    Daniel
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro launched with keyboard shortcut breaks after a "File Open" action
    By Skotzmun in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2013, 03:46 AM
  2. Printpreview
    By Manvinder8 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-21-2010, 12:15 AM
  3. [SOLVED] Macro focus issues
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2010, 09:25 AM
  4. [SOLVED] macro launched when condition is true
    By Dariusz Tomon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2006, 11:35 AM
  5. [SOLVED] printpreview
    By Alex in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2005, 06:05 PM

Tags for this Thread

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