How to detect if autotext entry is showing?

H

hstijnen

Hi,

I have defined some autotext entries: when I type some text, the autotext
entry is showing, and when I hit Enter the entry is inserted in the document.

Now I have created a KeyBinding for the Enter key: when the Enter key is
hit, a specific macro is executed. My question is: how can I detect in that
macro if the autotext entry is showing?

Thanks for help

Henk
 
J

Jean-Guy Marcil

hstijnen was telling us:
hstijnen nous racontait que :
Hi,

I have defined some autotext entries: when I type some text, the
autotext entry is showing, and when I hit Enter the entry is inserted
in the document.

Now I have created a KeyBinding for the Enter key: when the Enter key
is hit, a specific macro is executed. My question is: how can I

What are you doing with the Enter key?
As a user it would bother me in the extreme if my Enter key did not act as
expected....
This is why I never bind it.
detect in that macro if the autotext entry is showing?

I do not think you can do that easily.
The only way I can see is to monitor the Selection_Change event, and
consistently check if the last 4 characters are used in the first 4
characters of all autotext entries that are available right now (Normal.dot,
current document template and all global templates). Way too much
overhead....

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

hstijnen

Thanks, Jean-Guy,

is there perhaps a way to call the original built-in function of the enter
key in VBA?
 
J

Jean-Guy Marcil

hstijnen was telling us:
hstijnen nous racontait que :
Thanks, Jean-Guy,

is there perhaps a way to call the original built-in function of the
enter key in VBA?

Not that I know of. The Enter key is pretty standard in all aplications, it
adds line breaks or execute code behind a selected object.

Again, what are you trying to do?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

hstijnen

....what are you trying to do?
I've made a keybinding and macro to intercept the Enter. The goal is when
one is creating a list (bulleted, numbered), and hits Enter when the (last)
item is empty, the list is ended and the correct style is set (to create
distance between text and list). Thisworks pretty well.

BTW, I found that the autotext entry is also inserted when one hits TAB, so
that my problem has disappeared.

Thank you for your interest.

Salut,
Henk
 
J

Jean-Guy Marcil

hstijnen was telling us:
hstijnen nous racontait que :
...what are you trying to do?
I've made a keybinding and macro to intercept the Enter. The goal is
when one is creating a list (bulleted, numbered), and hits Enter when
the (last) item is empty, the list is ended and the correct style is
set (to create distance between text and list). Thisworks pretty well.

Interesting...
If you have 5 minutes and don't mind, could you share your code?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

hstijnen

Hi Jean-Guy,

By occasion I've found the answer for my Enterkey problem in
http://support.microsoft.com/kb/q187985/

the key code is:
CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
KeyCategory:=wdKeyCategoryMacro,
Command:="Normal.styles.EnterKeyMacro"

and in Normal.styles.EnterKeyMacro I can place the code I want: if one hits
Enter in a bulleted list and the paragraph is empty, then I only change the
style of the paragraph. In all other cases I do a TypeParagraph.

I run the above code in Normal.dot and then all docs on normal.dot have the
desired binding.

Cheers,

Henk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top