Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

popup menu

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sarah - 24 Feb 2005 15:12 GMT
im having huge problems with a popup menu.
Everytime i run the macro it creates a new shortcutmenu item however if i
run the mcro  few times i have the same menu item added everytime. I was
trying to code it so that if it already existed it would delete it and create
a new one using code like this :

Set clarpop = ShortCutMenu.Controls.Add(Type:=msoControlPopup)

For Each clarpop In ShortCutMenu.Controls
clarpop.Delete
Next clarpop

With clarpop
       .Tag = "Litriu"
       .Caption = "&Litriú"
       .OnAction = "MenuAction"
End With

However that was giving me errors
Then i tried an if statement saying if there were less than 11 controls on
the shortcutmenu to add a new one otherwise dont - that didnt show any menu
item.

deleting menu item seems to always throw errors.

Any word of advice??
Jean-Guy Marcil - 25 Feb 2005 00:06 GMT
sarah was telling us:
sarah nous racontait que :

> im having huge problems with a popup menu.
> Everytime i run the macro it creates a new shortcutmenu item however
[quoted text clipped - 7 lines]
> clarpop.Delete
> Next clarpop

Here, you add a menu, and then right away try to delete it.... ?
Also, you are trying to delete a control by defining a popup menu (You
define clarpop a popup menu, but then try to use that variable to cycle
through controls.

Are you trying to add a menu or a control? With your code, you are adding a
menu that will never be accessible because as soon as you put the focus on
it, the MenuAction macro is launched.

> With clarpop
>        .Tag = "Litriu"
[quoted text clipped - 8 lines]
>
> deleting menu item seems to always throw errors.

Try this instead:

'_______________________________________
Sub Test()

Dim MyCtrl As CommandBarControl
Dim ShortCutMenu As CommandBar

Set ShortCutMenu = CommandBars("Text")

For Each MyCtrl In ShortCutMenu.Controls
   If MyCtrl.Tag = "Litriu" Then
       MyCtrl.Delete
       Exit For
   End If
Next

Set MyCtrl = ShortCutMenu.Controls.Add(Type:=msoControlButton)

With MyCtrl
       .Tag = "Litriu"
       .Caption = "&Litri?"
       .OnAction = "MenuAction"
End With

End Sub
'_______________________________________

'_______________________________________
Sub MenuAction()

MsgBox """Litri?"" was clicked on!", vbInformation, "Success!"

End Sub
'_______________________________________

Finally, are you sure you want to add this control to Normal.dot?
If not, look up the
   CustomizationContext
property in the VBA on-line help.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.