PDA

View Full Version : Solved: Add "Paste Special" to the Right-Click Menu



Anne Troy
06-18-2004, 06:16 AM
How could I do that?

mark007
06-18-2004, 06:45 AM
Sub AddMenuButton()
Dim cb As CommandBar
Dim c As CommandBarButton
Set cb = Application.CommandBars("Text")
Set c = cb.Controls.Add(msoControlButton, 755, , 4, True)
With c
.Caption = "Paste &Special..."
.Style = msoButtonCaption
.TooltipText = "Paste Special"
End With
End Sub


:)

Anne Troy
06-18-2004, 06:55 AM
Okay. That works great. So, if I wanted this to ALWAYS be available to me on MY machine, I would:

Copy the code above.
Open Word.
Hit Alt+F11 to open the VBE.
On the left-hand pane, I'd double-click ThisDocument under Normal.
Then, on the right, I'd hit the dropdown and choose Document from the first dropdown, and New on the second dropdown, and paste only the following part of the code in between the Sub/End Sub.
I would do the same for Document-Open.
Correct?

Dim cb As CommandBar
Dim c As CommandBarButton
Set cb = Application.CommandBars("Text")
Set c = cb.Controls.Add(msoControlButton, 755, , 4, True)
With c
.Caption = "Paste &Special..."
.Style = msoButtonCaption
.TooltipText = "Paste Special"
End With

mark007
06-18-2004, 07:24 AM
I think this would do it:

Copy the code above.
Open Word.
Hit Alt+F11 to open the VBE.
On the left-hand pane, I'd double-click ThisDocument under Normal.
Then, on the right, I'd hit the dropdown and choose Document from the first dropdown, and Open on the second dropdown,

finally paste:

Dim cb As CommandBar
Dim c As CommandBarButton
Set cb = Application.CommandBars("Text")
Set c = cb.Controls.Add(msoControlButton, 755, , 4, True)
With c
.Caption = "Paste &Special..."
.Style = msoButtonCaption
.TooltipText = "Paste Special"
End With

In between the 2 lines created.

You only need it to run once when word i.e. the Normal template opens.

:)

Anne Troy
06-18-2004, 07:27 AM
You're correct. :)
Thanks!!

Anne Troy
06-21-2004, 10:04 AM
Mark: Can you paste the correct code here? :)
Our asker, who is not a member, says he gets the duplicate menus too.
I know you have emailed it to me, but I'd like it to be here, and don't want to do anything stupid.

Thanks!

Anne Troy
06-21-2004, 10:05 AM
Oh!
Also, Mark: Please post the code the user can run to get rid of the extra menus that he now has. :)

Zack Barresse
06-21-2004, 11:31 AM
Hi Anne,

Try these out, they worked for me:



Sub resetMenu()
With CommandBars("Text")
.Reset
End With
End Sub

Sub delSpecMenu()
With CommandBars("Text")
.Controls("Paste &Special...").Delete
End With
End Sub


The first one should reset the right-click menu to it's original state. The second one will delete a specific control, and must be specified.

ispy1009
06-25-2007, 01:32 PM
I am very new to writing VB code, and was wondering how to add other menu items. I am guess that this line "Set c = cb.Controls.Add(msoControlButton, 755, , 4, True)" is the line that indicates that paste special is the one wanted, but how do you know that this is for paste special? For example, what would the code be for "change case?" I think I understand all of the other lines of the code. Thanks for any help you can provide.

Ahikhteh
08-16-2008, 05:19 AM
Hi,
I also have the same question. How can I add a macro to the short menu that appears when I right click on my mouse in Microsoft Word. How can I change the this VBA? How can I specify a msoControlButton for my macro?
I'm not an expert.

Bhedad.