|
-
Jan 11th, 2006, 03:37 PM
#1
Thread Starter
Frenzied Member
Adding to MSWord Right Click Menu
Hi,
I pretty good with VB6, but haven't worked with VBA.
Here's what I want to do,
I have a list of words that have matching replacement words.
If the user selects and right clicks a word in his WOrd Doc, I want to search my list.
If the selected word is in the list I want to temp add a new option to the right click menu, the option would have a sub menu of the matching words from the list.
Example:
Code:
Cut
Copy
Paste
--------------
Optional Words
Repalcement1
Repalcement2
Repalcement3
I've been going through the help files and cobbled this together, but it's not quite it.
I supose I could add the replacment words to the combo, but I wouldn't know how to add them or what sub to add in order to react to a combobox click.
VB Code:
Public WithEvents appWord As Word.Application
Private Sub appWord_WindowBeforeRightClick _
(ByVal Sel As Selection, _
Cancel As Boolean)
Set myBar = CommandBars _
.Add(Name:="Custom", Position:=msoBarPopup, Temporary:=True)
With myBar
.Controls.Add Type:=msoControlButton, ID:=3
.Controls.Add Type:=msoControlComboBox
End With
myBar.ShowPopup
End Sub
-
Jan 13th, 2006, 02:42 PM
#2
Re: Adding to MSWord Right Click Menu
Looks like your on the right track but your loosing me on what the issue really is and whats going on with this combobox? I thought you needed a popup menu?
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 
-
Jan 13th, 2006, 06:12 PM
#3
Thread Starter
Frenzied Member
Re: Adding to MSWord Right Click Menu
I really wasn't after a combobox, it's just the only code I was able to find in the help files that came close to what I'm after.
It would be better if I could just add a new menu item ("Optional Words") and then add sub items.
But I haven't got a clue where to start.
Alternately I might be able to use the combobox, but I would need to know how to add items to it, and how to react to a click event for the box.
p.s.
I forgot to mention that the code from the 1st post is in a class module named "EventClassModule"
and there is a normal module named Module1 with the following code:
VB Code:
Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.appWord = Word.Application
End Sub
-
Jan 13th, 2006, 11:37 PM
#4
Re: Adding to MSWord Right Click Menu
Ok, you should use a different name for your custom menu item - Name:="Custom". Should be something that may not conflict with any reserved words amd related to its purpose.
VB Code:
Dim oCB1 As Office.CommandBarButton
With myBar
Set oCB1 = .Controls.Add Type:=msoControlButton, ID:=3
oCB1.Caption = "My Menu Caption1"
oCB1. ...
oCB1. ...
oCB1. ...
End With
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
|