ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What workbook is calling the function (https://www.excelbanter.com/excel-programming/304168-what-workbook-calling-function.html)

Pierre Laporte

What workbook is calling the function
 
I wrote a function that resides in an addin.

In the function I need to know what workbook is calling the function. It's
not the ActiveWorkbook, as the function may be called from a Workbook that
is dependant on the calling Workbook.

So the question is how do I determine the workbook that is calling the
function ?

Tks



keepITcool

What workbook is calling the function
 
dim wb as workbook

if typename(application.caller)="Range" then
set wb= application.caller.parent.parent
end if

sould do it :)


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Pierre Laporte" wrote:

I wrote a function that resides in an addin.

In the function I need to know what workbook is calling the function.
It's not the ActiveWorkbook, as the function may be called from a
Workbook that is dependant on the calling Workbook.

So the question is how do I determine the workbook that is calling the
function ?

Tks





Pierre Laporte

What workbook is calling the function
 
Works great, thanks keepITcool.

"keepITcool" wrote in message
...
dim wb as workbook

if typename(application.caller)="Range" then
set wb= application.caller.parent.parent
end if

sould do it :)


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Pierre Laporte" wrote:

I wrote a function that resides in an addin.

In the function I need to know what workbook is calling the function.
It's not the ActiveWorkbook, as the function may be called from a
Workbook that is dependant on the calling Workbook.

So the question is how do I determine the workbook that is calling the
function ?

Tks








All times are GMT +1. The time now is 04:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com