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 / October 2006

Tip: Looking for answers? Try searching our database.

Delete and backspace key interception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frédéric Laurent - 04 Oct 2006 20:08 GMT
Hello,

I intercept  the delete and backspace keystrokes in Word 2000-> 2003.
In most cases, there is no problem.

However, if a modal window (envelopes and labbels or "If... then...
Else in the mergefield functions for example) is open, it is impossible
to use the usual objects (selection...).
It is not a real problem because I do not have any treatment to do at
this time.

I thus want that the key "delete" behaves as usual. For that, I thought
using the following code:

   FindKey(BuildKeyCode(wdKeyDelete)).Disable
    SendKeys "{DEL}", True
   FindKey(BuildKeyCode(wdKeyDelete)).Rebind wdKeyCategoryMacro,
"ToucheSuppr"

But as I am in a modal window, the code blocks at the first line.

My question is: How to return to the normal behavior for a keystroke if
a modal window is open?

Thank you in advance for your assistance!

Frederic Laurent
Jean-Guy Marcil - 05 Oct 2006 02:15 GMT
Frédéric Laurent was telling us:
Frédéric Laurent nous racontait que :

> Hello,
>
[quoted text clipped - 21 lines]
>
> Thank you in advance for your assistance!

One way of doing this (and this might no be the best way) is to intercept
the commands that launches those modal windows.
For example, the envelopes and labels:

Sub ToolsEnvelopesAndLabels()
   'Insert your code here
   Dialogs(wdDialogToolsEnvelopesAndLabels).Show
   'Or here
End Sub

One way to easily create those subs is like this:

Tools > Macro > Macros... > (Macros in:) Word Commands
In the list, find the command that launches the modal window:
   e.g.: ToolsEnvelopesAndLabels
Select it,
(Macros in:) Document1 (or whatever document you want)
Create

I guess you should break your code in two subs (One before the Dialog call
and one after). Add a call to these subs before and after the Dialogs line
in each sub you create this way.

AS I said at the top, there must be a faster way. This is easy, but a bit
involved...

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.