I will admit when it comes to Macro's I just don't get it. My only experience with them was in Excel over 10 yrs ago and that was just "Recording" the steps I took to do some calculation.
If I understand correctly, a macro can be used to "Insert" code into my functions at compile time? If this is the case I have an idea that may or may not work.
If I have functions like the pseudo-code below
Can I add a macro to do something like
so that in essence it would be like I added the code to each Function/Sub myself that the layout would look something like
This may be an easy answer, or maybe I am way off base, but had to ask
If I understand correctly, a macro can be used to "Insert" code into my functions at compile time? If this is the case I have an idea that may or may not work.
If I have functions like the pseudo-code below
Code:
Function DoSomething1() AS LONG 'Do Something here and return a long End Function Function DoSomething2() AS STRING 'Do Something here and return a String End Function
Code:
macro Insert "On Error Goto ErrorHandler" as the 1st line in each function Insert "Exit Function" or "Exit Sub" on the line above my label for "ErrorHandler" Insert the label "Error Handler" Insert whatever error handling routines I need end macro Function DoSomething1() AS LONG 'Do Something here and return a long End Function Function DoSomething2() AS STRING 'Do Something here and return a String End Function
Code:
Function DoSomething1() AS LONG ON ERROR GOTO ErrorHandler 'Do Something here and return a long EXIT FUNCTION ErrorHandler: 'Error Handling routines End Function Function DoSomething2() AS STRING ON ERROR GOTO ErrorHandler 'Do Something here and return a String EXIT FUNCTION ErrorHandler: 'Error Handling routines End Function
Comment