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