简体   繁体   中英

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM