Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default VBA access to call stack

I need to know if a function has called a function. I'd like to not add
extra input arguments. Is there read access to the Call Stack or would a
Global Variable be the key here?

Thanks,
Matthew Pfluger
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default VBA access to call stack

I should also point out here that Application.Caller would not help since the
function is called through a Worksheet, and then that function calls other
functions.

The problem is that the second function transposes its array return if
called through the worksheet. This creates a single column, 2D array instead
of the 1D array the other functions are expecting.

Matthew Pfluger

"Matthew Pfluger" wrote:

I need to know if a function has called a function. I'd like to not add
extra input arguments. Is there read access to the Call Stack or would a
Global Variable be the key here?

Thanks,
Matthew Pfluger

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default VBA access to call stack

Not really following you. You want to know if a function has called a
function. By checking the call stack. But when a function is called it goes
on the stack and is then taken off the stack when it is done. You could
possibly use the stack to determine if a currently running function was
called by another function but not the other way around.

In either case you don't really have access to the call stack in code. You
can see it in the VBE but I am unaware of how to read the stack in code...
--
HTH...

Jim Thomlinson


"Matthew Pfluger" wrote:

I need to know if a function has called a function. I'd like to not add
extra input arguments. Is there read access to the Call Stack or would a
Global Variable be the key here?

Thanks,
Matthew Pfluger

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default VBA access to call stack

How about something like:


Public Function foo(byRef arg1 As Variant, _
Optional byVal RangeResult As Boolean = False) As Variant

Dim vArr As Variant

If Typeof Application.Caller is Range then RangeResult = True

'Function stuff here

If RangeResult Then
foo = Application.Transpose(vArr)
Else
foo = vArr
End If
End Function

Then your functions that call foo are responsible for determining
whether or not to return a result appropriate for a range, e.g.:

a = foo(b)

returns a 1-d array

a = foo(b, True)

returns a 2-d array

In article ,
Matthew Pfluger wrote:

I need to know if a function has called a function. I'd like to not add
extra input arguments. Is there read access to the Call Stack or would a
Global Variable be the key here?

Thanks,
Matthew Pfluger

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call a VBA module from Microsoft Access Nick Hodge Excel Programming 2 December 19th 06 05:41 PM
error 28: out of stack space call function ina Excel Programming 5 April 24th 06 07:26 PM
Call Stack disabled Martin Wheeler Excel Programming 2 July 8th 05 12:09 AM
call stack question William Barnes Excel Programming 3 December 21st 04 12:27 AM
call stack question Dave Ring Excel Programming 2 October 4th 03 02:01 AM


All times are GMT +1. The time now is 03:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"