...my signature?
Seems like this is the standard syntax people should be using for all macros now.
Optional - allows ribbon callbacks or direct referencing
Variant - allows 2003 backward compat
...my signature?
Seems like this is the standard syntax people should be using for all macros now.
Optional - allows ribbon callbacks or direct referencing
Variant - allows 2003 backward compat
Re: What do you think of...
lol
Re: What do you think of...
That's what makes it a good signature...
It sorta reads like a joke, but actually, I'm serious. That is (literally) the format that I'm going to use for all macros.
It does actually make sense.
Re: What do you think of...
QuoteThat is (literally) the format that I'm going to use for all macros.
Why?
Re: What do you think of...
Quote from Dave HawleyWhy?
Alright, a little background...
If you want to call a macro from the ribbon, the syntax of the macro must be:
Above is the typical code example provided online, in books and so forth...
I was converting a bunch of my old macros to use with the ribbon and I was just adding the above control syntax. I ran into a problem when some of my macros were making calls to their subroutine buddies that now had this control variable requirement.
There are 3 ways you can solve that problem:
1) make the IRibbonControl optional, or...
2) dimension a DummyRibbon as an IRibbonControl and pass it
3) create a seperate sub with the IRibbonControl variable that makes the call to MyMacro without the control requirement
The first option above obviously makes more sense because it requires no additional coding in subs that call MyMacro and it also works fine if you happen to assign macros to shape click events (as I often do).
So, if I want to allow my macros to be called directly or from the ribbon it seems to make sense to always use the following "Optional" syntax.
Now, if I want to write my macros so I can run the code in Excel 2003 or 2007 I have a new problem; the IRibbonControl did not exist in Excel 2003. As it turns out, the Ribbon doesn't necessarily care if it's allowed to pass along itself to a routine that is setup to receive a Variant as opposed to an IRibbonControl, and we know that Excel 2003 allows Variants. So now I have this final syntax that allows for direct and ribbon calling in Excel 2007, and will also work if someone tries to run the code in Excel 2003.
I saw Ger Plante's suggestion to change the name of the variable from "control" to "variable". Obviously, it can be named anything you want. I'll probably leave mine as "control" just because it reminds me of the origin of why I included it. I'm also hopeful that when people see it in my signature, the "control" reference might help them to make the lateral connection.
Re: What do you think of...
Hey, guys. Good thread. Shouldn't it be moved into the public domain part of Oz?
Re: What do you think of...
Hi Tom
Yes. Aaron can I move this thread to the havachat forum?
Re: What do you think of...
Sure, if you like...
Don’t have an account yet? Register yourself now and be a part of our community!