+ Reply to Thread
Results 1 to 4 of 4

Workbook Open macro not performing as expected

  1. #1
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Workbook Open macro not performing as expected

    Hi all,

    I am using this code to do a few things when the user opens the workbook:

    Please Login or Register  to view this content.
    Initially I minimise the ribbon and lastly I zoom the page to the the screen size. For some reason both of these events will not run in the order written. If I comment out the hide the ribbon code the screen maximise works but if I don't it doesn't work as I think it should. When the hide ribbon code is active it seems as if the zoom is running first and then the ribbon is being hidden leaving the zoom looking quite small.

    Does the sendkey code only trigger when the macro finishes even though it is earlier in the code than the zoom?

    If so is there a way around this?

    Thanks for your help.
    Marcus

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Workbook Open macro not performing as expected

    Marcus

    Instead of using SendKeys trying running this to show/hide the ribbon.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: Workbook Open macro not performing as expected

    Hi there Norie,

    Tried it and I get this error:

    object variable or with block variable not set

    Any ideas?

    Cheers,
    Marcus

  4. #4
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: Workbook Open macro not performing as expected

    Ok I got this to work:

    Please Login or Register  to view this content.
    but it still does not seem to execute the code in order. The zoom still happens prior to the minimisation of the ribbon even though the code is not in that order.

    On the 15.4 inch screen I am using the workbook zooms to 87% when the ribbon is visible and 97% when the ribbon is minimised. If I save and close the workbook with the ribbon visible and then open the file the Workbook Open code runs and the workbook is zoomed (shrunk in this instance) to 87%. If I run the zoom code again with the ribbon now minimised to zoom corrects to 97% which is now perfect for my screen size.

    Hope that makes sense.

    Marcus

+ 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] IF function not performing as expected
    By L.LEE in forum Excel General
    Replies: 3
    Last Post: 07-01-2016, 01:32 AM
  2. macro to copy cells(Range) from an open Workbook to another open Workbook.
    By jbester in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2013, 09:47 AM
  3. Macro to open a closed workbook and select copy cells into an open workbook
    By helloganesh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2013, 02:00 PM
  4. [SOLVED] Macro to copy data from open workbook to next open line of new workbook
    By nhtodd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2012, 09:42 PM
  5. vbTextCompare not performing as expected in vba
    By johnmerlino in forum Excel General
    Replies: 4
    Last Post: 07-10-2011, 02:49 PM
  6. If Then Else not performing as expected
    By Alexander40 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2009, 05:06 PM
  7. auto_open macro not performing as expected
    By Eric Winegarner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2005, 06:06 PM

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