ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I check if a pop-up menu exists... (https://www.excelbanter.com/excel-programming/380897-how-can-i-check-if-pop-up-menu-exists.html)

Lakehills

How can I check if a pop-up menu exists...
 
Hi All,

Help with another (probably easy for you all) question. I use the code
below to add a pop-up menu that runs a macro.

On Error Resume Next
With Application
.CommandBars("Cell").Controls("GICAP Formatter").Delete
Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=False )
End With

With cBut
.Caption = "GICAP Formatter"
.Style = msoButtonCaption
.OnAction = "FormatIssuesWorkSheet"
End With

What I need to know is how to check if the pop-up menu exists the next
time the workbook is opened? The "on error" process doesn't work for me
in this case because I need this check in the middle of a subroutine.
However, I continue in the subroutine whether it exists or not.

Can someone help?

Thanks,
Chris


Phillip[_5_]

How can I check if a pop-up menu exists...
 


What I need to know is how to check if the pop-up menu exists the next
time the workbook is opened? The "on error" process doesn't work for me
in this case because I need this check in the middle of a subroutine.
However, I continue in the subroutine whether it exists or not.

Can someone help?

Thanks,
Chris


This works for me Phillip London UK

Dim x As Long
For x = 1 To Application.CommandBars("Cell").Controls.Count
If Application.CommandBars("Cell").Controls(x).Captio n = "GICAP
Formatter" Then
MsgBox "It Exists"
End If
Next


NickHK

How can I check if a pop-up menu exists...
 
Chris,
Not sure what you are after, but you can change the error trapping employed
in a routine:

Private Sub CommandButton1_Click()
Dim i

'Activate the error handler
On Error GoTo Handler
'Some code
i = 1 / 0

'Change to Resume Next
On Error Resume Next
'Some code to skip over error
i = 1 / 0

'No error handling
On Error GoTo 0
'More code, although this will stop execution
i = 1 / 0

'Activate the error handler, again
On Error GoTo Handler
i = 1 / 0

Exit Sub
Handler:
'Deal with the error
'Here we just resume next statement
Resume Next
End Sub

NickHK

"Lakehills" wrote in message
oups.com...
Hi All,

Help with another (probably easy for you all) question. I use the code
below to add a pop-up menu that runs a macro.

On Error Resume Next
With Application
.CommandBars("Cell").Controls("GICAP Formatter").Delete
Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=False )
End With

With cBut
.Caption = "GICAP Formatter"
.Style = msoButtonCaption
.OnAction = "FormatIssuesWorkSheet"
End With

What I need to know is how to check if the pop-up menu exists the next
time the workbook is opened? The "on error" process doesn't work for me
in this case because I need this check in the middle of a subroutine.
However, I continue in the subroutine whether it exists or not.

Can someone help?

Thanks,
Chris





All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com