+ Reply to Thread
Results 1 to 5 of 5

Get name of workbook calling a common .xla on network drive

  1. #1
    Registered User
    Join Date
    11-14-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2003
    Posts
    3

    Get name of workbook calling a common .xla on network drive

    We have several workbooks on user machines which all access a common library .xla file residing on a network drive.

    We need to add logging functionality in the xla addin, which will log the name of the workbook that is making any call to the sub/function in the .xla and the username who is using the workbook. How do we get the workbook name and username from within the xla?

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Get name of workbook calling a common .xla on network drive

    Regards File Name invoking the call - assuming invoked from a cell:

    Please Login or Register  to view this content.
    Regards username

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-14-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Get name of workbook calling a common .xla on network drive

    Thanks. But the code to get the workbook name does not work. Application.Caller.Parent is null. Please note that my workbook has a button which is bound to a macro defined in the workbook. This macro then makes a call to the add-in function. While debugging, I found that Application.Caller is the button object, but Application.Caller.Parent is null.
    Also what is the difference between Environ("username") and Application.UserName ?

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

    Re: Get name of workbook calling a common .xla on network drive

    If it's triggered by button click, then just Activeworkbook.name should work. As regards user names, environ gives you the network login, whereas application.username gives you whatever has been entered in Excel options.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    11-14-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Get name of workbook calling a common .xla on network drive

    Thanks. It works fine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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