RE: Problem Overriding Word menu items using VSTO 2005... Shortcuts no
- From: Ken Laws [MSFT] <KenLawsMSFT@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Jun 2005 11:49:08 -0700
Hi Shawn,
The code that you've implemented essentially allows you to hook the click
event of the Paste button, however, using the CTRL+V keyboard shortcut to
execute the paste would not execute the click event of the Paste menu item
which is why your code isn't getting executed.
There are a couple of ways that I've found that would allow you to trap and
override the CTRL+V shortcut.
1. Create a keyboard hook which would allow you to trap and handle a
scenario where the user presses CTRL+V.
For more information regarding using a keyboard hook take a look at the
following MSDN documentation.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/lowlevelkeyboardproc.asp
2. Another option that is easier to implement and appears to handle not
only the scenario where a user presses CTRL+V but also if the user clicks the
Paste item on the menu is to add a VBA macro to the Microsoft Word document
named EditPaste.
Example
=============
Sub EditPaste()
MsgBox "Pasting"
End Sub
=============
Hope this helps!
If you have any questions please let me know via the posting.
Regards,
Ken Laws
Microsoft Support
This posting is provided "AS IS" with no warranties, and confers no rights.
For more information regarding Visual Studio Tools for Office 2005:
Best of Blogs: Visual Studio 2005 Tools for Office
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_2003_ta/html/odc_landvsto2005_ta.asp
Visual Studio Tools for Office Forum
http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=16
Visual Studio Tools for the Microsoft Office System
http://msdn.microsoft.com/office/understanding/vsto/default.aspx
"Shawn Hogan" wrote:
> Hi Everyone,
>
> I'm trying to override the menu Paste item using VSTO 2005 but I'm having
> problems. It seems that if i click the menu item(Edit\Paste or right click
> paste) my event code works but if i use the shortcut keys(CTRL-V) my event
> code does not fire.
>
> What i've done so far is obtain the paste menu item from Word using the
> command bars object like so:
>
> Declare my object as
> private withevents pasteMenuItem as microsoft.office.core.commandBarButton
>
> in Startup i have
> pasteMenuItem = thisdocument.CommandBars("Edit").controls("Paste")
>
> In the click event of the menu control i put a message box just to show me
> that it fires...
> Msgbox "pasting"
>
> What am i doing wrong? Any workarounds? Any alternate methods?
>
> Thanks,
> Shawn
>
>
>
>
.
- Prev by Date: Re: Deploy a VSTO tool to 100 users...
- Next by Date: Re: Create Word Document from ASP.NET
- Previous by thread: Outlook Samples
- Next by thread: Re: Create Word Document from ASP.NET
- Index(es):
Loading