+ Reply to Thread
Results 1 to 4 of 4

Private Sub Workbook_Activate() Applying to Specific Workbook Only

  1. #1
    Registered User
    Join Date
    06-13-2018
    Location
    Glasgow
    MS-Off Ver
    2013
    Posts
    33

    Private Sub Workbook_Activate() Applying to Specific Workbook Only

    I am trying to apply Activate functions to one workbook only.

    the current code I have is
    HTML Code: 
    When I open another workbook, File Menu, etc does not show. I am relatively new to VBA and I am assuming there is a minor change that I need to carry out to make this work.

    Could someone give me some guidance please?

    Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,085

    Re: Private Sub Workbook_Activate() Applying to Specific Workbook Only

    Not really. Event handlers relate to the workbook or worksheet they are in. Usually/often you would use the .Activate event handler to take some action when the workbook/worksheet is activated/selected and the .DeActivate event handler to reverse the actions.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,491

    Re: Private Sub Workbook_Activate() Applying to Specific Workbook Only

    these settings
    Application.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"",False)"
    Application.DisplayFormulaBar = False

    are not limited to the workbook but apply to the excel application
    you can achieve the same result with
    Application.DisplayFullScreen = True

    This will also hide the ribbon and formulabar. but at any time you can leave fullscreen mode by pressing escape (ESC) so nothing is changed in the settings of the application

    try this code instead.
    Please Login or Register  to view this content.
    another way would be to also have a Workbook_BeforeClose event where you restore the ribbon and formulabar. But my suggestion woould be to avoid this manipulation of the excel applicaiton itself because you can unwantedly alter a users preferred setup by handling these settings.
    It is not up to you to decide how to setup a users Excel application. So use less invasive tools like display full screen or zoom to get visible in one screen what needs to be seen in one screen.
    Last edited by Roel Jongman; 03-25-2019 at 10:16 AM. Reason: clarified a sentense

  4. #4
    Registered User
    Join Date
    06-13-2018
    Location
    Glasgow
    MS-Off Ver
    2013
    Posts
    33

    Re: Private Sub Workbook_Activate() Applying to Specific Workbook Only

    Thanks Roel.

    That worked a treat. Thanks for your help.

+ 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. Workbook_Activate not triggering
    By donwb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2018, 05:58 PM
  2. [SOLVED] Workbook_activate or workbook_open?
    By Lv27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2012, 05:23 AM
  3. [SOLVED] Workbook_activate - why doesn't it work
    By Lv27 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2012, 02:50 PM
  4. Replies: 2
    Last Post: 07-25-2010, 02:24 PM
  5. Workbook_Activate and Workbook_Open
    By caliskier in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2010, 12:49 PM
  6. two code starting private sub workbook open in a same workbook
    By ss_bb_24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2008, 05:54 AM
  7. Workbook_Activate question
    By Peter Rooney in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-17-2005, 06:25 AM

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