+ Reply to Thread
Results 1 to 8 of 8

Workbook Open in VBA

  1. #1
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Workbook Open in VBA

    Hello Excel friends,

    I have the following in a module to make it automatically open Workbook B when I open Workbook A. It doesn't automatically open B. When I go to the module and click the RUN button, it opens B.
    On the top it does say (General) on the left and Workbook_Open on the right.
    Will someone please tell me what I'm doing wrong?

    Thanks so much.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Workbook Open in VBA

    It needs to go in the ThisWorkbook module, not a standard module.

  3. #3
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Workbook Open in VBA

    Thank you very much. It works like a charm.
    For educational purposes, will you please share with me (and everyone else who learns in ExcelForum) why this is so, or how one should know or recognize that ThisWorkbook should be used here?
    Thanks!

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Workbook Open in VBA

    Thread moved to proper forum. Please be careful when posting. Thx

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Workbook Open in VBA

    Open is an event exposed by the Workbook. All such events need to be in the ThisWorkbook module, just as worksheet specific events should go in the relevant worksheet code module.

    If you wanted to put the code in a normal module, you could just rename the routine as Auto_Open rather than Workbook_Open.
    Rory

  6. #6
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Workbook Open in VBA

    Thanks again . . . I'll make a mental note of that.
    Good day!

  7. #7
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Workbook Open in VBA

    Hello Pepe Le Mokko,
    This is in the (Excel Programming / VBA / Macros) forum for a question about placing code in VBA.
    What forum should it have been in?
    Thanks

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Workbook Open in VBA

    No, it was in the Formula sub-forum. I moved it to the right place

+ 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. Open another workbook find match copy row to open workbook.
    By skyblues in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2018, 11:41 AM
  2. Macro VBA to copy and paste cells from one open workbook to another open workbook
    By bloomingcarrot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2014, 07:55 PM
  3. Open Workbook if closed, keep open if open, insert password
    By jwahl16 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-09-2013, 04:09 PM
  4. 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
  5. 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
  6. [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
  7. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 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