PC Review


Reply
Thread Tools Rate Thread

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

 
 
Lakehills
Guest
Posts: n/a
 
      10th Jan 2007
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

 
Reply With Quote
 
 
 
 
Phillip
Guest
Posts: n/a
 
      11th Jan 2007

>
> 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).Caption = "GICAP
Formatter" Then
MsgBox "It Exists"
End If
Next

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      11th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check whether URL exists Greg Lovern Microsoft Excel Programming 1 15th Mar 2011 11:13 PM
DSN, Check if exists Bernie Hunt Microsoft ADO .NET 2 10th Apr 2006 04:40 PM
Check url exists Pete Microsoft ASP .NET 1 29th Nov 2004 04:13 PM
Check to see if Doc exists Ryan Microsoft Access Form Coding 7 14th Nov 2003 10:19 PM
check if url exists tom Microsoft Dot NET 1 11th Sep 2003 10:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:19 PM.