Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Command Bar
Hi all, is it possible to know, with code, which button has been
activated with vba as i would like to use an if statement. I create the bar with the code below. Sub addToolbarQ() ' Application.DisplayAlerts = False Dim oCBMenuBar As CommandBar Dim oCBCLeave As CommandBarControl Dim iMenu As Integer Dim i As Integer On Error Resume Next Application.CommandBars("ZA-TM-RECON").Delete Application.IgnoreRemoteRequests = True Set oCBMenuBar = Application.CommandBars.Add(Name:="ZA-TM-RECON") With oCBMenuBar With .Controls.Add(Type:=msoControlButton) .BeginGroup = True .FaceId = 3 .TooltipText = "Save file" .OnAction = "restoreToolbarsQ" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 4 .TooltipText = "Print Document" .OnAction = "GetPeriodQ1" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 271 .TooltipText = "Save Recon to process later" .OnAction = "SaveToQuery1" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 363 .TooltipText = "Send this document to the supplier" .OnAction = "InsertColumnsQ" End With With .Controls.Add(Type:=msoControlButton) .BeginGroup = True .FaceId = 108 .TooltipText = "Adopt all changes" .OnAction = "AdoptAllPriceDiff" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 387 .TooltipText = "Adopt changes individually" .OnAction = "AdoptPriceDiffSep" End With ' With .Controls.Add(Type:=msoControlButton) ' .FaceId = 157 ' .TooltipText = "Last month" ' .OnAction = "lastMonth" ' End With ' With .Controls.Add(Type:=msoControlButton) ' .BeginGroup = True ' .Caption = "Summary" ' .Style = msoButtonCaption ' .TooltipText = "Show summary sheet" ' .OnAction = "gotoSummary" ' End With .Position = msoBarTop .Protection = msoBarNoMove .Visible = True End With End Sub Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Command Bar
Hi Les,
You can use CommandBars.ActionControl to get at any of the properties of the activated button, such as Caption, Tag or Parameter. So each onACtion should point to the same macro, then test as mentioned, and call subservient macros appropriately. -- HTH RP (remove nothere from the email address if mailing direct) "Les Stout" wrote in message ... Hi all, is it possible to know, with code, which button has been activated with vba as i would like to use an if statement. I create the bar with the code below. Sub addToolbarQ() ' Application.DisplayAlerts = False Dim oCBMenuBar As CommandBar Dim oCBCLeave As CommandBarControl Dim iMenu As Integer Dim i As Integer On Error Resume Next Application.CommandBars("ZA-TM-RECON").Delete Application.IgnoreRemoteRequests = True Set oCBMenuBar = Application.CommandBars.Add(Name:="ZA-TM-RECON") With oCBMenuBar With .Controls.Add(Type:=msoControlButton) .BeginGroup = True .FaceId = 3 .TooltipText = "Save file" .OnAction = "restoreToolbarsQ" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 4 .TooltipText = "Print Document" .OnAction = "GetPeriodQ1" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 271 .TooltipText = "Save Recon to process later" .OnAction = "SaveToQuery1" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 363 .TooltipText = "Send this document to the supplier" .OnAction = "InsertColumnsQ" End With With .Controls.Add(Type:=msoControlButton) .BeginGroup = True .FaceId = 108 .TooltipText = "Adopt all changes" .OnAction = "AdoptAllPriceDiff" End With With .Controls.Add(Type:=msoControlButton) .FaceId = 387 .TooltipText = "Adopt changes individually" .OnAction = "AdoptPriceDiffSep" End With ' With .Controls.Add(Type:=msoControlButton) ' .FaceId = 157 ' .TooltipText = "Last month" ' .OnAction = "lastMonth" ' End With ' With .Controls.Add(Type:=msoControlButton) ' .BeginGroup = True ' .Caption = "Summary" ' .Style = msoButtonCaption ' .TooltipText = "Show summary sheet" ' .OnAction = "gotoSummary" ' End With .Position = msoBarTop .Protection = msoBarNoMove .Visible = True End With End Sub Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Command Bar
Hi Bob, thanks will give it a bash.
best regards, Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
One command in one cell initiating another command in another cel. | Excel Worksheet Functions | |||
command code ( GOTO command) in formula | New Users to Excel | |||
command button add another command | Excel Discussion (Misc queries) | |||
Pivot Table Error Message - "Command Text not set for command obje | Excel Discussion (Misc queries) | |||
I want to combine a "match" command with a copy and paste command. | Excel Programming |