+ Reply to Thread
Results 1 to 6 of 6

A problem when running program code residing in another workbook

  1. #1
    Registered User
    Join Date
    02-13-2016
    Location
    Belgium
    MS-Off Ver
    MsOffice 2013
    Posts
    4

    A problem when running program code residing in another workbook

    I have two workbooks: WbCode.xlsm containing my program code and WbData.xlsx containg a button to run the program that resides in WbCode.xlsm.

    When both workbooks are opened, everything runs fine when pressing the button: the program does what it is supposed to do and the selected sheet in WbData.xlsx remains active (visible on my screen).
    When only WbData.xlsx is open, something strange happens when pressing the button: Excel opens WbCode.xlsm and starts the program and the program does what it is supposed to do. But, when finished, WbCode.xlsm becomes active. I now have to select WbData.xlsx explicitly to see the result.

    I already added
    Please Login or Register  to view this content.
    at the end of the program, but no changes: WbCode.xlsm still becomes active.

    Any suggestion to circumvent this annoying problem ?

  2. #2
    Registered User
    Join Date
    01-03-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: A problem when running program code residing in another workbook

    workbooks("WbData").activate
    workbooks("WbData").worksheets("Sheet1").select ' change sheet to which one you want to show up

  3. #3
    Registered User
    Join Date
    02-13-2016
    Location
    Belgium
    MS-Off Ver
    MsOffice 2013
    Posts
    4

    Re: A problem when running program code residing in another workbook

    Unfortunately, adding the second instruction does not solve the problem: WbCode.xlsm remains active...

  4. #4
    Registered User
    Join Date
    01-03-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: A problem when running program code residing in another workbook

    Try this open two blank books. select the BOOK2 and minimize it then run the following

    Please Login or Register  to view this content.
    that should open up book2

  5. #5
    Registered User
    Join Date
    02-13-2016
    Location
    Belgium
    MS-Off Ver
    MsOffice 2013
    Posts
    4

    Re: A problem when running program code residing in another workbook

    I do not understand the goal of this test:
    First, the workbook holding the program code is assigned to Wb and then, after some Wb2.Activate's, Wb is activated.
    My goal is to have the workbook without the code (Wb2 in your test) activated.

    And, when changing your test into
    Please Login or Register  to view this content.
    the workbook holding the program code is, strange enough, activated.

  6. #6
    Registered User
    Join Date
    02-13-2016
    Location
    Belgium
    MS-Off Ver
    MsOffice 2013
    Posts
    4

    Re: A problem when running program code residing in another workbook

    I tested my 2 workbooks with Excel 2007 and everything runs fine: when pressing the button, Excel opens WbCode.xlsm (if not already opened), runs the program and WbData.xlsx remains active...
    I guess Excel 2013 handles this kind of requests in another way as Excel 2007 does.
    So, my question is still standing: how can I circumvent (in Excel 2013) the problem that my code workbook becomes activated ?

+ 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. Replies: 1
    Last Post: 04-20-2014, 05:48 PM
  2. Running the same code twice in the same workbook
    By aarond5 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-04-2013, 05:30 PM
  3. [SOLVED] problem in running worksheet_change code
    By vipulhumein in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-13-2013, 12:36 PM
  4. VBA Delete Code not running in full program
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2010, 12:04 AM
  5. Problem with a program code
    By highjumper in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2005, 12:14 PM
  6. repeated screen "blinking" problem when running program - please help!
    By gunman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2005, 06:14 PM
  7. [SOLVED] Problem running code behind a userform
    By cdb in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-10-2005, 12: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