How do you reference the workbook that called an Addin from the Addin in Excel?
In Excel 2010, I have an开发者_Python百科 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
精彩评论