Lance Roberts
Lance Roberts

Reputation: 22842

How do you reference the workbook that called an Addin from the Addin in Excel?

In Excel 2010, I have an Addin that is called from the Ribbon XML file from the main workbook.

How do I reference the workbook (I really need its path) that called the Addin from within the Addin?

For Example, I can use ThisWorkbook to reference the workbook with the code in it (in this case the Addin). Is there anything similar to reference the calling workbook?

Upvotes: 3

Views: 1926

Answers (2)

user688334
user688334

Reputation:

Two possibilities I can think of....

1.From the main add-in pass

ThisWorkbook.Name and/or ThisWorkbook.Path

or

2.Identify the Window/Class Name from API see Get Window Handle

Upvotes: 0

Doug Glancy
Doug Glancy

Reputation: 27478

If you know it's the Active workbook, which would be true if the user clicked a button, then you can use:

Activeworkbook.Fullname

You may have to store it in a workbook variable earlier if other workbooks become active before you're doing the processing in question.

Upvotes: 1

Related Questions