+ Reply to Thread
Results 1 to 5 of 5

get the name of the first workbook that opened this workbook

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

    get the name of the first workbook that opened this workbook

    Workbook A is not mine. Workbook A has an Author but a different current user.

    Workbook B is mine.

    Workbook A code opens workbook B, loads data to B and INITIATES code IN Workbook B to make calculations in and save Workbook B.
    I want to capture the Author (not the current user) of Workbook A. I don’t know the name of the file.

    How do I capture the name of Workbook A that opened my workbook B so I can get its Author?

    I can only add code to my own Workbook B.

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: get the name of the first workbook that opened this workbook

    Somewhere in your code you can tell your macro to save the author name of all open workbooks.

    You'll have to loop through all open workbooks storing the name of the workbook (.name) and the author (.BuiltinDocumentProperties("Last Author"))

    It's referred to in code like: thisworkbook.name or thisworkbook.BuiltinDocumentProperties("Last Author")

    so something like

    Please Login or Register  to view this content.

    You'll then have to use your own judgement as to which workbook / author is correct. The issue is you don't know how many other workbooks are open on the PC of the fella who opens workbook A. I'm assuming you also don't know the name of workbook A.
    Last edited by BellyGas; 11-07-2016 at 10:42 AM.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: get the name of the first workbook that opened this workbook

    If you put this in the ThisWorkbook code module of WorkbookB, it will capture the workbook the is active when WorkbookB is opened.
    That workbook may or may not be Workbook A. (One can call a macro from a non-active workbook)

    Please Login or Register  to view this content.
    Code like this will return the author of that workbook

    Please Login or Register  to view this content.
    Last edited by mikerickson; 11-07-2016 at 10:45 AM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: get the name of the first workbook that opened this workbook

    If Workbook A is the only file that is open first maybe you can get the name using this.

    Please Login or Register  to view this content.
    You code would have set wbk before it opens Workbook B. You could also use activeworkbook in place of Workbooks(Workbooks.Count) which would be the last workbook opened.

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

    Re: get the name of the first workbook that opened this workbook

    PreviousWB is exactly what I wanted

    Thanks a million!


    Quote Originally Posted by mikerickson View Post
    If you put this in the ThisWorkbook code module of WorkbookB, it will capture the workbook the is active when WorkbookB is opened.
    That workbook may or may not be Workbook A. (One can call a macro from a non-active workbook)

    Please Login or Register  to view this content.
    Code like this will return the author of that workbook

    Please Login or Register  to view this content.

+ 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. [SOLVED] Copy a Worksheet from a Closed Workbook to the Current Opened Workbook
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-28-2014, 12:55 PM
  2. copying data from a recently opened workbook to the workbook where the form is present
    By Sivaramakrishnan31 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 12:03 PM
  3. Use a macro to extract cell data from opened workbook to new opened workbook
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2014, 01:35 PM
  4. Replies: 0
    Last Post: 04-26-2013, 03:40 AM
  5. Need to Copy Columns from Previous Workbook to Newly Opened Workbook
    By BYizz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-06-2012, 06:33 AM
  6. VBA button to store data from 1 workbook and paste it in another UN-opened workbook
    By mountaineerhughes in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-26-2012, 11:39 AM
  7. Replies: 2
    Last Post: 01-19-2006, 06:00 AM

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