VBA Macro that tests for a specific keystroke

A

apasko

I am a beginner but have a quick VBA question using Word 2000.

I would like some help with a code the does the following:

A macro begins that starts a numbering sequence (I have that below.),
when a user types the ? a few returns and an indent are entered then
the macro continues to number until the macro is ended by the user.

I am having a difficult time understanding how to test for the user
typing the ?

Thank you.

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"AUTONUMLGL ", PreserveFormatting:=False
Selection.TypeText Text:=vbTab
 
J

Jezebel

Not surprising you're having a hard time of it. VBA doesn't have any easy
way to monitor keystrokes in the document. There is no KeyPress event for
the document itself.

Nor do macros run concurrently with user input into the body of the
document.

What are you actually trying to do?
 
G

Greg

That isn't ever going to happen with a macro. You could enter a SEQ
field, type the first question including the question mark, type the
return, the indent, and the next SEQ field. Next select the question
mark, return, indent, and field and save it as an AUTOTEDT (maybe
?next).

User type a question, enters ?next and AUTOTEXT does the rest.
 
W

Word Heretic

G'day "Jezebel" <[email protected]>,

Can't remember what it is, but there IS a routine that fires when the
user presses Enter that can be used to trap for forming new
paragraphs.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Jezebel reckoned:
 
J

Jezebel

You can use Window.SelectionChange which will get some keyboard actions, but
not simple keystrokes. Apart from that you need to use API calls. But
obviously the wrong approach in this case.
 

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