Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I tried
..onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default .onaction, passing arguments

I have never understood why anyone wants to set a parameter value in an
onaction, because it is static, so it defeats the objectives of parameters.
However, that being so, this is how to do it

.OnAction = "'mymacro ""hello""'"

A better way in my view is to test with the macro some of the control button
properties, like so

Sub mymacro()
With Application.CommandBars.ActionControl
If .Tag < "" Then
MsgBox .Tag
End If
End With
End Sub


which you can set dynamically in the code like so

With Application.CommandBars("Standard").Controls("Test ")
If somevalue 17 Then
.Tag = "hello"
Else
.Tag = "goodbye"
End If
End With


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx
and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I
tried
.onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default .onaction, passing arguments

Just a heads up, (and another reason not to use it)

.OnAction = "'mymacro ""hello""'"

is undocumented and in my experience doesn't work with every version of
excel.

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote:

I have never understood why anyone wants to set a parameter value in an
onaction, because it is static, so it defeats the objectives of parameters.
However, that being so, this is how to do it

.OnAction = "'mymacro ""hello""'"

A better way in my view is to test with the macro some of the control button
properties, like so

Sub mymacro()
With Application.CommandBars.ActionControl
If .Tag < "" Then
MsgBox .Tag
End If
End With
End Sub


which you can set dynamically in the code like so

With Application.CommandBars("Standard").Controls("Test ")
If somevalue 17 Then
.Tag = "hello"
Else
.Tag = "goodbye"
End If
End With


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx
and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I
tried
.onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, what's 'wrong' with the following?
1. Theoretically, if a macro can be called by .onaction = stuff, or by
another sub, keeping the control testing out of that macro makes it more
'independant'?

2. Are you saying that if a macro has to perform let's say 4 processes,
where much of the code is the same, that I should write 4 subs and NOT vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws, processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the left
or right, arg = "hide" or "move", but I'd like to draw a line in the sand
when arg = "delete" or arg = "insert".

Thanks for your expertise.
Neal
--
Neal Z


"Bob Phillips" wrote:

I have never understood why anyone wants to set a parameter value in an
onaction, because it is static, so it defeats the objectives of parameters.
However, that being so, this is how to do it

.OnAction = "'mymacro ""hello""'"

A better way in my view is to test with the macro some of the control button
properties, like so

Sub mymacro()
With Application.CommandBars.ActionControl
If .Tag < "" Then
MsgBox .Tag
End If
End With
End Sub


which you can set dynamically in the code like so

With Application.CommandBars("Standard").Controls("Test ")
If somevalue 17 Then
.Tag = "hello"
Else
.Tag = "goodbye"
End If
End With


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx
and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I
tried
.onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, what's 'wrong' with the following?
1. Theoretically, if a macro can be called by .onaction = stuff, or by
another sub, keeping the control testing out of that macro makes it more
'independant'?

2. Are you saying that if a macro has to perform let's say 4 processes,
where much of the code is the same, that I should write 4 subs and NOT vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws, processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the left
or right, arg = "hide" or "move", but I'd like to draw a line in the sand
when arg = "delete" or arg = "insert".

Thanks for your expertise.
Neal
--
Neal Z


"Tom Ogilvy" wrote:

Just a heads up, (and another reason not to use it)

.OnAction = "'mymacro ""hello""'"

is undocumented and in my experience doesn't work with every version of
excel.

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote:

I have never understood why anyone wants to set a parameter value in an
onaction, because it is static, so it defeats the objectives of parameters.
However, that being so, this is how to do it

.OnAction = "'mymacro ""hello""'"

A better way in my view is to test with the macro some of the control button
properties, like so

Sub mymacro()
With Application.CommandBars.ActionControl
If .Tag < "" Then
MsgBox .Tag
End If
End With
End Sub


which you can set dynamically in the code like so

With Application.CommandBars("Standard").Controls("Test ")
If somevalue 17 Then
.Tag = "hello"
Else
.Tag = "goodbye"
End If
End With


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx
and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I
tried
.onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, the objectives of paramerter's are to vary the processing is
what's being called, no? So, I guess I don't see the difference between A)
in 4 menu choices calling the same sub with 1 of 4 arg values. the onaction
may be status but the user choice via menu is not, versus, B) testing
that choice "inside" the macro being called?? . Your thoughts, please

1. Theoretically, if a macro can be called by .onaction = stuff, or by
another sub, keeping the control testing out of that macro makes it more
'independant'?

2. Are you saying that if a macro has to perform let's say 4 processes,
where much of the code is the same, that I should write 4 subs and NOT vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws, processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the left
or right, arg = "hide" or "move", but I'd like to draw a line in the sand
when arg = "delete" or arg = "insert" depending upon the name chosen.

Thanks for your expertise.
Neal
--
Neal Z


"Bob Phillips" wrote:

I have never understood why anyone wants to set a parameter value in an
onaction, because it is static, so it defeats the objectives of parameters.
However, that being so, this is how to do it

.OnAction = "'mymacro ""hello""'"

A better way in my view is to test with the macro some of the control button
properties, like so

Sub mymacro()
With Application.CommandBars.ActionControl
If .Tag < "" Then
MsgBox .Tag
End If
End With
End Sub


which you can set dynamically in the code like so

With Application.CommandBars("Standard").Controls("Test ")
If somevalue 17 Then
.Tag = "hello"
Else
.Tag = "goodbye"
End If
End With


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx
and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I
tried
.onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, the objectives of paramerter's are to vary the processing is
what's being called, no? So, I guess I don't see the difference between A)
in 4 menu choices calling the same sub with 1 of 4 arg values. the onaction
may be status but the user choice via menu is not, versus, B) testing
that choice "inside" the macro being called?? . Your thoughts, please

1. Theoretically, if a macro can be called by .onaction = stuff, or by
another sub, keeping the control testing out of that macro makes it more
'independant'?

2. Are you saying that if a macro has to perform let's say 4 processes,
where much of the code is the same, that I should write 4 subs and NOT vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws, processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the left
or right, arg = "hide" or "move", but I'd like to draw a line in the sand
when arg = "delete" or arg = "insert" depending upon the name chosen.

Thanks for your expertise.
Neal

--
Neal Z


"Bob Phillips" wrote:

I have never understood why anyone wants to set a parameter value in an
onaction, because it is static, so it defeats the objectives of parameters.
However, that being so, this is how to do it

.OnAction = "'mymacro ""hello""'"

A better way in my view is to test with the macro some of the control button
properties, like so

Sub mymacro()
With Application.CommandBars.ActionControl
If .Tag < "" Then
MsgBox .Tag
End If
End With
End Sub


which you can set dynamically in the code like so

With Application.CommandBars("Standard").Controls("Test ")
If somevalue 17 Then
.Tag = "hello"
Else
.Tag = "goodbye"
End If
End With


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Hi All,
Am just getting into toolbars and custom menus that will call macros.
Docum says in summary, for toolbars, .onaction = "MyMacro" 'with xxx
and
_ end with not shown.

Well, I've got macros whose function varies via arguments.
e.g. call RealMacro(arg1)

Haven't yet read Walkenbach's chapter on menus, but as a heads-up I
tried
.onaction = Run Macname "arg value" but of course it errored out.

So, it seems unless there's a better way, that I'll have to have an
"intermediate"
call whe (in sorta pseudo code)
.onaction = "MyMacA"
.onaction = "MyMacB"

sub MyMacA()
call RealMacro("arg value A")
end sub

sub MyMacB()
call RealMacro("arg value B")
end sub

Am I getting warm ?

--
Neal Z




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default .onaction, passing arguments

I am only going to answer once, couldn't bear to type it out 4 time <g

--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, the objectives of paramerter's are to vary the processing
is
what's being called, no? So, I guess I don't see the difference between
A)
in 4 menu choices calling the same sub with 1 of 4 arg values. the
onaction
may be status but the user choice via menu is not, versus, B) testing
that choice "inside" the macro being called?? . Your thoughts, please

1. Theoretically, if a macro can be called by .onaction = stuff, or by
another sub, keeping the control testing out of that macro makes it more
'independant'?



I am not suggesting not testing in the macro, just not using a parameter as
the way to pass the variable.


2. Are you saying that if a macro has to perform let's say 4 processes,
where much of the code is the same, that I should write 4 subs and NOT
vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws, processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the
left
or right, arg = "hide" or "move", but I'd like to draw a line in the sand
when arg = "delete" or arg = "insert" depending upon the name chosen.



Not at all, just use a different method. As I showed you, you can set a
property of the commandbar control at any point in your code, and you can
test that property very easily within the OnAction macro using
Application.CommandBars.ActionControl which points at the currently
activated control.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

First, Apologies on the qty of times I TRIED to get the indentation correct
on prior responses, I never meant for you to read and/or type it more than
1x.

I think I understand your point, but I just wanted to make sure our language
is in synch. I keep saying arguments, and you keep saying parameter, so
......

call Macname(ABC, DEF)

I call ABC and DEF arguments which I think is MSo's term for them in most of
the Help. Is your name for them parameters?

If so, you think it's a crappy idea to pass their value via onaction, but
rather to test their values in a separate piece of code with the called
Macname.

Thanks,
Neal



--
Neal Z


"Bob Phillips" wrote:

I am only going to answer once, couldn't bear to type it out 4 time <g

--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, the objectives of paramerter's are to vary the processing
is
what's being called, no? So, I guess I don't see the difference between
A)
in 4 menu choices calling the same sub with 1 of 4 arg values. the
onaction
may be status but the user choice via menu is not, versus, B) testing
that choice "inside" the macro being called?? . Your thoughts, please

1. Theoretically, if a macro can be called by .onaction = stuff, or by
another sub, keeping the control testing out of that macro makes it more
'independant'?



I am not suggesting not testing in the macro, just not using a parameter as
the way to pass the variable.


2. Are you saying that if a macro has to perform let's say 4 processes,
where much of the code is the same, that I should write 4 subs and NOT
vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws, processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the
left
or right, arg = "hide" or "move", but I'd like to draw a line in the sand
when arg = "delete" or arg = "insert" depending upon the name chosen.



Not at all, just use a different method. As I showed you, you can set a
property of the commandbar control at any point in your code, and you can
test that property very easily within the OnAction macro using
Application.CommandBars.ActionControl which points at the currently
activated control.



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default .onaction, passing arguments

In my terminology, the variable declared in a procedure signature the
arguments, and the values that are passed to the procedure parameters. They
are different beasts in my mind, and require a different label.

So in this procedure

Function myFunc(ByVal msg As String)

MsgBox msg
End Function

msg is an argument.

In the call, such as

sText = "hello"
Call muFunc(sText)

sText is a parameter.

I am not saying it is a crappy idea to pass their value via onaction (I
probably am, but even I would not be so blunt as that <g), but I am saying
it is pointless IMO. If you define a commandbar control with a parameter
value, what is the point? That value is fixed, and non-changeable, so why
not just build the value into the procedure? You cannot create a situation,
at least I cannot see how, when invoking that control will ever pass any
value other than the one originally defined, which defeats the objectives of
parameters/arguments to me. To make the procedure able to respond
differently to changing situations, you need another method, such as the one
I showed. And then there is Tom's comment about it not necessarily working
in all versions of Excel. Can't say I have come across this myself, but I
wouldn't use that technique so it is not likely I would, and Tom knows what
he is talking about. Summary, pointless, possibly dangerous ... nah, on
reflection I think it is a great idea.


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
First, Apologies on the qty of times I TRIED to get the indentation
correct
on prior responses, I never meant for you to read and/or type it more than
1x.

I think I understand your point, but I just wanted to make sure our
language
is in synch. I keep saying arguments, and you keep saying parameter, so
.....

call Macname(ABC, DEF)

I call ABC and DEF arguments which I think is MSo's term for them in most
of
the Help. Is your name for them parameters?

If so, you think it's a crappy idea to pass their value via onaction, but
rather to test their values in a separate piece of code with the called
Macname.

Thanks,
Neal



--
Neal Z


"Bob Phillips" wrote:

I am only going to answer once, couldn't bear to type it out 4 time <g

--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, the objectives of paramerter's are to vary the
processing
is
what's being called, no? So, I guess I don't see the difference
between
A)
in 4 menu choices calling the same sub with 1 of 4 arg values. the
onaction
may be status but the user choice via menu is not, versus, B)
testing
that choice "inside" the macro being called?? . Your thoughts, please


1. Theoretically, if a macro can be called by .onaction = stuff, or
by
another sub, keeping the control testing out of that macro makes it
more
'independant'?



I am not suggesting not testing in the macro, just not using a parameter
as
the way to pass the variable.


2. Are you saying that if a macro has to perform let's say 4
processes,
where much of the code is the same, that I should write 4 subs and NOT
vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws,
processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the
left
or right, arg = "hide" or "move", but I'd like to draw a line in the
sand
when arg = "delete" or arg = "insert" depending upon the name chosen.



Not at all, just use a different method. As I showed you, you can set a
property of the commandbar control at any point in your code, and you can
test that property very easily within the OnAction macro using
Application.CommandBars.ActionControl which points at the currently
activated control.







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .onaction, passing arguments

Hi Bob,
Well, the fog is lifting. Thanks so much for the time you took to explain.
This 'last' reply needs no response unless you're so inclined after
reading the last question at the bottom. It concerns $.
Allow me to explain a bit... as briefly as I can, I've been in apps
development a ton of years in large corporate mainframe environments, and am
building a whoppingly large add-in(at least for a 1st timer like me) which I
hope to sell to the newspaper industry. Since 9/11 when I got "laid-off", I
am entirely self taught in VBA along with Walkenbach's 2003 programming book
and the expertise of guys like you on this site. Note: The add-in is a
result of my delivering newspapers for a while to help make ends meet.
As my first foray into toolbars and menu bars, your 1st answer initially
made no sense to me due to my lack of understanding of the basic control
itself, as well as no experience with the object model of toolbars and menus.
Of course what you say makes sense, and I will follow the advice.

I am about two months away from competing this project. I am SURE I don't
know the 'dangers' I'm going to run into when and if my add-in gets sold, but
I will be looking for help which I will PAY for.

Last question:
Do you want me to send you the eventual RFP as I try to round up the help
I will
need ?
My email is below, at least in the copy of the message I'm looking at. If
you can't see it, then I've clicked the notify me box, so send me something I
can use to contact you the 'right' way. Again, many thanks.
Neal




--
Neal Z


"Bob Phillips" wrote:

In my terminology, the variable declared in a procedure signature the
arguments, and the values that are passed to the procedure parameters. They
are different beasts in my mind, and require a different label.

So in this procedure

Function myFunc(ByVal msg As String)

MsgBox msg
End Function

msg is an argument.

In the call, such as

sText = "hello"
Call muFunc(sText)

sText is a parameter.

I am not saying it is a crappy idea to pass their value via onaction (I
probably am, but even I would not be so blunt as that <g), but I am saying
it is pointless IMO. If you define a commandbar control with a parameter
value, what is the point? That value is fixed, and non-changeable, so why
not just build the value into the procedure? You cannot create a situation,
at least I cannot see how, when invoking that control will ever pass any
value other than the one originally defined, which defeats the objectives of
parameters/arguments to me. To make the procedure able to respond
differently to changing situations, you need another method, such as the one
I showed. And then there is Tom's comment about it not necessarily working
in all versions of Excel. Can't say I have come across this myself, but I
wouldn't use that technique so it is not likely I would, and Tom knows what
he is talking about. Summary, pointless, possibly dangerous ... nah, on
reflection I think it is a great idea.


--
HTH

Bob

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

"Neal Zimm" wrote in message
...
First, Apologies on the qty of times I TRIED to get the indentation
correct
on prior responses, I never meant for you to read and/or type it more than
1x.

I think I understand your point, but I just wanted to make sure our
language
is in synch. I keep saying arguments, and you keep saying parameter, so
.....

call Macname(ABC, DEF)

I call ABC and DEF arguments which I think is MSo's term for them in most
of
the Help. Is your name for them parameters?

If so, you think it's a crappy idea to pass their value via onaction, but
rather to test their values in a separate piece of code with the called
Macname.

Thanks,
Neal



--
Neal Z


"Bob Phillips" wrote:

I am only going to answer once, couldn't bear to type it out 4 time <g

--
HTH

Bob

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

"Neal Zimm" wrote in message
...
Bob and Tom, thanks. I won't use the technique, (glad to hear that it's
undocumented, 'cuz I looked pretty hard for it and could not find any.)

To Bob's point, the objectives of paramerter's are to vary the
processing
is
what's being called, no? So, I guess I don't see the difference
between
A)
in 4 menu choices calling the same sub with 1 of 4 arg values. the
onaction
may be status but the user choice via menu is not, versus, B)
testing
that choice "inside" the macro being called?? . Your thoughts, please


1. Theoretically, if a macro can be called by .onaction = stuff, or
by
another sub, keeping the control testing out of that macro makes it
more
'independant'?


I am not suggesting not testing in the macro, just not using a parameter
as
the way to pass the variable.


2. Are you saying that if a macro has to perform let's say 4
processes,
where much of the code is the same, that I should write 4 subs and NOT
vary
the function via an argument?
e.g. In my app it's prudent to control several worksheet, ws,
processes,
so I have an array of 'reserved' ws names.
I don't mind a user hiding the ws or shifting its ws name tab to the
left
or right, arg = "hide" or "move", but I'd like to draw a line in the
sand
when arg = "delete" or arg = "insert" depending upon the name chosen.


Not at all, just use a different method. As I showed you, you can set a
property of the commandbar control at any point in your code, and you can
test that property very easily within the OnAction macro using
Application.CommandBars.ActionControl which points at the currently
activated control.






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
Macro - onAction arguments version83 Excel Worksheet Functions 2 April 10th 10 09:59 PM
OnAction with arguments supported RB Smissaert Excel Programming 0 March 14th 06 02:01 PM
passing parameters to OnAction Michel Pierron Excel Programming 8 October 29th 04 11:59 PM
.OnAction with arguments max Excel Programming 4 February 23rd 04 06:30 PM
How do you add arguments to an OnAction event? Jason[_27_] Excel Programming 5 November 21st 03 12:48 PM


All times are GMT +1. The time now is 05:54 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"