Intercept {Enter} key in VBA

T

Tim

I have written a routine "InsertPageBreak" that checks the Selection range
to ensure that no bookmarks will be split by insertion of the page break.

I would like to do the same for whenever the {Enter} key is pressed to
start a new paragraph, but I can't find a Word command that is initiated
by the {Enter} keystroke.

All help is greatly appreciated.
 
J

Jonathan West

Hi Tim,

You can assign the Enter key to a macro if you want to.

Unfortunately, neither the Enter key nor the Tab key can be assigned to a
macro using the Tools Customize dialog. However, you can write a small bit
of VBA that assigns them to a macro. This article shows you how

Assigning a macro to the tab key
http://word.mvps.org/FAQs/MacrosVBA/AssignMacroToTab.htm

To assign the Enter key, just use wdKeyReturn instead of wdKeyTab.
 
T

Tim

Looks good. Thanks for the infor.

Jonathan West said:
Hi Tim,

You can assign the Enter key to a macro if you want to.

Unfortunately, neither the Enter key nor the Tab key can be assigned to a
macro using the Tools Customize dialog. However, you can write a small bit
of VBA that assigns them to a macro. This article shows you how

Assigning a macro to the tab key
http://word.mvps.org/FAQs/MacrosVBA/AssignMacroToTab.htm

To assign the Enter key, just use wdKeyReturn instead of wdKeyTab.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
 

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