|
-
Mar 3rd, 2005, 09:17 AM
#1
Thread Starter
Lively Member
word vba popup menu
i have a popup menu and i want there to be no more than two controls on it as some of the controls i add are duplicating
is there anyway of saying only add control if there are less than two controls already.
or else saying if controls.count > 2 then delete the last one in?
here's my code for adding a control
With clarpop.Controls.Add(Type:=msoControlButton, Temporary:=True)
.Caption = Trim(mi)
.Visible = True
.BeginGroup = True
.FaceId = 163
End With
thanks
-
Mar 3rd, 2005, 10:49 AM
#2
Junior Member
Re: word vba popup menu
hi
assuming that clarpop is a CommandBarPopup...
VB Code:
If (clarpop.Count < 2) Then
With clarpop.Controls.Add(Type:=msoControlButton, Temporary:=True)
.Caption = Trim(mi)
.Visible = True
.BeginGroup = True
.FaceId = 163
End With
End If
-
Mar 3rd, 2005, 12:01 PM
#3
Re: word vba popup menu
You need to use the Control collection of the popup.
VB Code:
If (clarpop.Controls.Count < 2) Then
With clarpop.Controls.Add(Type:=msoControlButton, Temporary:=True)
.Caption = Trim(mi)
.Visible = True
.BeginGroup = True
.FaceId = 163
End With
End If
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2005, 04:24 AM
#4
Junior Member
Re: word vba popup menu
RobDog please implement some kind of Code-Completion into the message editor
-
Mar 7th, 2005, 04:45 AM
#5
New Member
Steve 
-
Mar 7th, 2005, 12:49 PM
#6
Re: word vba popup menu
Something like this. It will search for the menuitem and if it doesnt already exist then it will add it.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim oApp As Word.Application
Dim oMenu As Office.CommandBar
Dim clarpop As Office.CommandBarPopup
Dim oTemp As Office.CommandBarButton
Set oApp = New Word.Application
Set oMenu = oApp.CommandBars("Menu Bar")
Set clarpop = oMenu.Controls("YourPopup")
Set oTemp = oMenu.FindControl(msoControlButton, "ItsID", "AnyTagValue", False, True)
If TypeName(oTemp) <> "Nothing" Then
'Already exists
Else
With clarpop.Controls.Add(msoControlButton, True)
.Caption = Trim(mi)
.Visible = True
.BeginGroup = True
.FaceId = 163
End With
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|