Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Possible to know who has called a function ?

Hi to all,

I would like to know if it is possible to know who has called a certain
function.

For example, I have three functions "printPage", "printPage1",
"printPage2" which can called another function "PrintToPdf".
I'm am in the "PrintToPdf" function. Is it possible to know which
function has called me ?

Thks for your answer

Best regards

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Possible to know who has called a function ?

Isabelle,

There is no way to programmatically determine what procedure
called another procedure. In debug mode, you can view the call
stack (View menu, Call Stack), but this is not available
programmatically.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Isabelle Robin" wrote in message
...
Hi to all,

I would like to know if it is possible to know who has called a

certain
function.

For example, I have three functions "printPage", "printPage1",
"printPage2" which can called another function "PrintToPdf".
I'm am in the "PrintToPdf" function. Is it possible to know

which
function has called me ?

Thks for your answer

Best regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Possible to know who has called a function ?

Chip's right, but if you wanted to edit your code you could always pass the
routine a parameter.

Sub MySub(strCaller as string)
debug.print strCaller
'do stuff
End Sub

Calling routines like this

Sub1
MySub "1"
End Sub

Sub 2
MySub "2"
End Sub

Robin Hammond
www.enhanceddatasystems.com

"Chip Pearson" wrote in message
...
Isabelle,

There is no way to programmatically determine what procedure
called another procedure. In debug mode, you can view the call
stack (View menu, Call Stack), but this is not available
programmatically.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Isabelle Robin" wrote in message
...
Hi to all,

I would like to know if it is possible to know who has called a

certain
function.

For example, I have three functions "printPage", "printPage1",
"printPage2" which can called another function "PrintToPdf".
I'm am in the "PrintToPdf" function. Is it possible to know

which
function has called me ?

Thks for your answer

Best regards





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Possible to know who has called a function ?

Isabelle,

You can use a different argument in each calling function,
then identify the argument in the called function, something like...

'-----------------------
Function PrintPage()
PrintToPdf (0)
End Function

Function PrintPage1()
PrintToPdf (1)
End Function

Function PrintPage2()
PrintToPdf (2)
End Function

Function PrintToPdf(ByRef F As Long)
Select Case F
Case 0
'Do some code
MsgBox F
Case 1
'Do different code
MsgBox F
Case 2
'Do really different code
MsgBox F
End Select
End Function
'--------------------------

Regards,
Jim Cone
San Francisco, CA


"Isabelle Robin" wrote in message
...
Hi to all,
I would like to know if it is possible to know who has called a certain
function.
For example, I have three functions "printPage", "printPage1",
"printPage2" which can call another function "PrintToPdf".
I'm am in the "PrintToPdf" function. Is it possible to know which
function has called me ?
Thks for your answer
Best regards



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
How do I know which cell a function is called from? Murami Excel Worksheet Functions 3 November 24th 06 02:22 PM
What is this function called?? jPaulB Excel Discussion (Misc queries) 3 August 4th 06 08:33 PM
Function, dont know what its called Michael Excel Worksheet Functions 1 May 8th 06 09:47 PM
mystery function called 'TABLE' SongBear Excel Worksheet Functions 7 January 7th 05 04:56 AM
Determining whether function called by Excel or VBA Ryan Poth[_2_] Excel Programming 3 July 17th 03 05:26 AM


All times are GMT +1. The time now is 06:50 AM.

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

About Us

"It's about Microsoft Excel"