+ Reply to Thread
Results 1 to 2 of 2

was workbook opene by VBA or by a user directly

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    was workbook opene by VBA or by a user directly

    I need to put code in WB1 WorkbookOpen to determine if WB1 (ThisWorkbook) was opened via code in another workbook (WB2) or by a user directly.

    There are too many existing WB2(s), that I don't have access to, in our company automatically opening the workbook I'm concerned about, so:
    - I can't use a cell value or named range value that changes when it's opened by code, as I can't change the code in all the WB2s
    - I can't disable events in WB2 before opening WB1 via code, as I can't change the code in all the WB2s
    - I can't password protect WB1, as I can't change the code in all the WB2s

    UserControl doesn't work because that's checking the Application not the workbook.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: was workbook opene by VBA or by a user directly

    Hi carsto,

    Difficult situation, especially since you can't control the father workbooks.

    In your situation, I don't know how to determine if the workbook was opened by VBA.

    However, you can determine if it was opened not by VBA. Sub Auto_Open() will run after Workbook_Open(). It will not run if workbook is opened programmatically (i.e. by VBA).

    Put Auto_Open() in an ordinary code module such as Module1:
    Sub Auto_Open()
      MsgBox "Auto_Open(): Workbook was NOT opened by VBA."
    End Sub
    I hope this helps.

    Lewis

+ 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. Pasting values that do not link directly to another workbook
    By Ezzard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2015, 02:26 PM
  2. [SOLVED] User input on worksheet to directly edit or amend code in VBA
    By Crooza in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2014, 06:35 PM
  3. Trying to import CSV directly to XLSM workbook
    By dovermac in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 07-24-2014, 05:06 PM
  4. [SOLVED] Excel vba user form- open directly to user form not worksheet
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 04-24-2013, 05:07 PM
  5. Need button in workbook that links directly to a chart.
    By aschroer in forum Excel General
    Replies: 1
    Last Post: 03-08-2006, 11:55 AM
  6. [SOLVED] The first workbook I open in excel causes book 1 to also be opene.
    By manders in forum Excel General
    Replies: 3
    Last Post: 01-21-2005, 02:06 PM
  7. Replies: 9
    Last Post: 01-19-2005, 01: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