+ Reply to Thread
Results 1 to 8 of 8

Personal.Xlsb Workbook.Activate not working

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Personal.Xlsb Workbook.Activate not working

    I'm trying to get a macro working in the personal workbook that I've done before, but for some reason it's not working now.

    What I need is when a workbook has sufficiently loaded (or activated), for the macro in the personal xlsb to run.
    At the moment, I'm putting the code in the This Workbook part of the personal xlsb and the following works fine:
    Private Sub Workbook_Open
    msgbox ("test")
    End Sub
    But if I replace Workbook_Open with Workbook_Activate, the message box doesn't pop up.

    Suggestions on how to get this working please?
    Last edited by Aaron092; 10-22-2014 at 10:21 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Personal.Xlsb Workbook.Activate not working

    The Personal workbook is hidden so will never be active, therefore the activate event won't fire.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: Personal.Xlsb Workbook.Activate not working

    Ahh. That makes sense. Is there any way around this please, or am I up everyones favourite creek?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Personal.Xlsb Workbook.Activate not working

    Are you trying to run the macro when any workbook activates or specifically after the personal macro workbook is loaded?

  5. #5
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: Personal.Xlsb Workbook.Activate not working

    On any workbook.
    The code checks if the workbook has a string in its name, and then selects a specific sheet if that exists.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Personal.Xlsb Workbook.Activate not working

    Then you need an application-level event sink.
    Private WithEvents app as Excel.Application
    Private Sub Workbook_Open
    Set app = Application
    End Sub
    Private Sub app_WorkbookActivate(ByVal Wb As Workbook)
        If Instr(1, wb.name, "some text", vbtextcompare) > 0 then wb.sheets("sheet name").select
    End Sub
    for example.

  7. #7
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: Personal.Xlsb Workbook.Activate not working

    thank you, romperstomper. Works exactly as needed

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Personal.Xlsb Workbook.Activate not working

    Glad to 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. Add procedure to PERSONAL.XLSB with a macro from another workbook.
    By dimattia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-31-2013, 10:21 AM
  2. How to save code under VBAProject(PERSONAL.XLSB) that applies to any workbook
    By bubai in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2013, 08:01 AM
  3. [SOLVED] Working with WorkBook Close event and Personal.xlsb files
    By coreytroy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-09-2013, 12:40 AM
  4. Run-Time Error 1004 When Running Macro from Another Personal Workbook (xlsb)
    By vcs1161 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2013, 12:05 PM
  5. Move or copy macro from Personal.xlsb to workbook
    By kazphilips in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2012, 05:26 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