Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Parsing paramters

Hi NG

Sometime when using callbacks e.g. .OnAction then it could be nice to pass
some parameters to the macro. Does anyone have a suggestion on how that
might be accomplished.

Mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Parsing paramters

Mark,

I think you sent me on a wild goose chase there. You don't mean Callbacks do
you? As to passing a parameter to OnACtion, that is easily achieved with

Here is an example from my system

sAction = "'PERSONAL.XLS'!'PasteComments ""Bob"'"
.OnACtion = sACtion

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
Hi NG

Sometime when using callbacks e.g. .OnAction then it could be nice to pass
some parameters to the macro. Does anyone have a suggestion on how that
might be accomplished.

Mark




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Parsing paramters

There is a method to do it, but it is unsupported and I believe xl2002 and
beyond don't support it anymore.

Sub SetAction()
Selection.OnAction = "'mymacro 1, 2'"
End Sub


Sub mymacro(one, two)
MsgBox one & " " & two
End Sub

so enclose the string in single quotes.

--
Regards,
Tom Ogilvy


"Mark" wrote in message
...
Hi NG

Sometime when using callbacks e.g. .OnAction then it could be nice to pass
some parameters to the macro. Does anyone have a suggestion on how that
might be accomplished.

Mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Parsing paramters

With Commandbars("Mybar").Controls.Add(type:=msoControl Button)
.Caption = "MS1"
.OnAction = "MySub"
.Parameter = 1
End with
With Commandbars("Mybar").Controls.Add(type:=msoControl Button)
.Caption = "MS2"
.OnAction = "MySub"
.Parameter = 2
End With

Then in your sub:

Public Sub MySub()
For i = 1 to CommandBars.ActionControl.Parameter
'Do stuff once or twice
Next i
End Sub

or

Public Sub MySub()
If CommandBars.ActionControl.Parameter = 1 Then
'Do Stuff for button MS1
ElseIF CommandBars.ActionControl.Parameter = 2 Then
'Do Stuff for button MS2
Else
MsgBox "Don't Understand " & _
CommandBars.ActionControl.Parameter


In article , "Mark"
wrote:

Hi NG

Sometime when using callbacks e.g. .OnAction then it could be nice to pass
some parameters to the macro. Does anyone have a suggestion on how that
might be accomplished.

Mark


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
Paramters or Arugment Auto-Label for User-Defined Function [email protected] Excel Worksheet Functions 5 April 22nd 08 06:21 PM
Parsing Saxman[_2_] Excel Discussion (Misc queries) 3 July 30th 07 04:36 PM
Database query with a range of cells as paramters? heprox Excel Discussion (Misc queries) 0 January 18th 07 11:15 PM
Instead of Parsing Krish Excel Discussion (Misc queries) 1 November 4th 06 08:32 PM
Parsing help Richard[_12_] Excel Programming 0 July 27th 03 12:50 PM


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