Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default variable or propertie 'name' for self written sub or function

Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default variable or propertie 'name' for self written sub or function

No, afraid not, we would all love there to be one.

What I do is to create a global variable, and set it at the head of each
procedure, painful, but I know of no better way.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jantje" wrote in message
oups.com...
Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default variable or propertie 'name' for self written sub or function

Thanks Bob!
Your method is also an option for me.
It would have been a nice feature though...


On 15 feb, 12:14, "Bob Phillips" wrote:
No, afraid not, we would all love there to be one.

What I do is to create a global variable, and set it at the head of each
procedure, painful, but I know of no better way.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jantje" wrote in message

oups.com...



Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default variable or propertie 'name' for self written sub or function

It sure would, as would a property that tells you the calling procedure.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jantje" wrote in message
ups.com...
Thanks Bob!
Your method is also an option for me.
It would have been a nice feature though...


On 15 feb, 12:14, "Bob Phillips" wrote:
No, afraid not, we would all love there to be one.

What I do is to create a global variable, and set it at the head of each
procedure, painful, but I know of no better way.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Jantje" wrote in message

oups.com...



Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default variable or propertie 'name' for self written sub or function

Jan,

See http://www.cpearson.com/excel/InsertProcedureNames.htm for code that
will automatically insert a CONST statement in to each procedure in a
module. The value of the CONST declaration is the name of the procedure that
contains it. Once you run this, you can use that constant's name (which you
supply) in your error handling message. E.g,

ErrHandler:
MsgBox "Error: " & CStr(Err.Number) & vbCrLf & _
"Descsrption: " & Err.Description & vbCrLf & _
"In Procedu " & C_PROC_NAME

Where C_PROC_NAME is the constant containing the name of the procedure. You
choose the name "C_PROC_NAME" (it can be any syntactically correct constant
name) and the code automatically insert into each procedure in the module a
declaration like

Const C_PROC_NAME = "MyProcName"

The code on the page http://www.cpearson.com/excel/InsertProcedureNames.htm
assume that you are somewhat familiar, at least at a conceptual level, with
using VBA code to write more VBA code. This is described in some detail with
lots of examples on www.cpearson.com/excel/vbe.htm


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Jantje" wrote in message
oups.com...
Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default variable or propertie 'name' for self written sub or function

You're an old Tandem/NSK man, Bob. We could do this in TACL. What was it,
#ROUTINENAME? Something like that. And in TAL, not only could you read the
Call Stack to see who called the current procedure, but you could also
modify the Call Stack and the variables before the beginning of the local
stack storage to have one procedure return to a procedure different that the
one that called it. I never found a good practical reason to send the
return to different proc, but I sure had fun writing code to do it. Just for
amusement, of course.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Bob Phillips" wrote in message
...
It sure would, as would a property that tells you the calling procedure.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Jantje" wrote in message
ups.com...
Thanks Bob!
Your method is also an option for me.
It would have been a nice feature though...


On 15 feb, 12:14, "Bob Phillips" wrote:
No, afraid not, we would all love there to be one.

What I do is to create a global variable, and set it at the head of each
procedure, painful, but I know of no better way.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Jantje" wrote in message

oups.com...



Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default variable or propertie 'name' for self written sub or function

Ah, the good old days! I was on Tandem's before TACL, and really appreciated
it when it was introduced.

Bob



"Chip Pearson" wrote in message
...
You're an old Tandem/NSK man, Bob. We could do this in TACL. What was it,
#ROUTINENAME? Something like that. And in TAL, not only could you read the
Call Stack to see who called the current procedure, but you could also
modify the Call Stack and the variables before the beginning of the local
stack storage to have one procedure return to a procedure different that
the one that called it. I never found a good practical reason to send the
return to different proc, but I sure had fun writing code to do it. Just
for amusement, of course.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Bob Phillips" wrote in message
...
It sure would, as would a property that tells you the calling procedure.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Jantje" wrote in message
ups.com...
Thanks Bob!
Your method is also an option for me.
It would have been a nice feature though...


On 15 feb, 12:14, "Bob Phillips" wrote:
No, afraid not, we would all love there to be one.

What I do is to create a global variable, and set it at the head of
each
procedure, painful, but I know of no better way.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Jantje" wrote in message

oups.com...



Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default variable or propertie 'name' for self written sub or function

On 15 feb, 14:47, "Chip Pearson" wrote:
Jan,

Seehttp://www.cpearson.com/excel/InsertProcedureNames.htmfor code that
will automatically insert a CONST statement in to each procedure in a
module. The value of the CONST declaration is the name of the procedure that
contains it. Once you run this, you can use that constant's name (which you
supply) in your error handling message. E.g,

ErrHandler:
MsgBox "Error: " & CStr(Err.Number) & vbCrLf & _
"Descsrption: " & Err.Description & vbCrLf & _
"In Procedu " & C_PROC_NAME

Where C_PROC_NAME is the constant containing the name of the procedure. You
choose the name "C_PROC_NAME" (it can be any syntactically correct constant
name) and the code automatically insert into each procedure in the module a
declaration like

Const C_PROC_NAME = "MyProcName"

The code on the pagehttp://www.cpearson.com/excel/InsertProcedureNames.htm
assume that you are somewhat familiar, at least at a conceptual level, with
using VBA code to write more VBA code. This is described in some detail with
lots of examples onwww.cpearson.com/excel/vbe.htm

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLCwww.cpearson.com
(email address is on the web site)

"Jantje" wrote in message

oups.com...



Hi, i just made a small sub 'logError' that writes the date, time,
err.Number and err.Description to a specified worksheet. I also want
to write the name of the Sub or Function that caused the error to be
raised...
Now i have to change the parameter each time i'm using the statement
'logError Date, Time, Err.Number, Err.Description, "name for sub or
function" '.
Can someone tell me if there's a variable to use that has the name of
a self made sub or function?
I hope the question is clear enough...
Thanks
jan- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -


Thank you very much Chip, I'll give this one a try...
unfortunately i have lots of procedures/functions on
worksheet_activate's (and less in modules)... but I think this will
come in handy...
Greetz,
Jan

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 to use the function written in VBA in excel sheet kelly Excel Discussion (Misc queries) 1 October 30th 07 08:53 AM
how to use the function written in VBA in excel sheet kelly Excel Discussion (Misc queries) 0 October 30th 07 08:24 AM
set the bottom propertie of a label zz Excel Programming 1 January 5th 07 06:35 PM
function to convert whole numbers to written text Mani K Excel Worksheet Functions 2 December 29th 05 09:24 AM
Accesing a combobox control via it index propertie in VBA, Is itPossible? Muxer Excel Programming 3 July 30th 03 08:20 PM


All times are GMT +1. The time now is 11:49 PM.

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"