Select a bookmark after an AutoText item is entered?

C

Charles Warner

Hello,

I have a number of AutoText entries that have bookmarks contained in
them.

Ideally, I'd like to just type the AutoText "Entry Name" in the
document, press Enter (as one would normally enter AutoText), and
then have the cursor go back and select the first Bookmark in the
AutoText entry.

Any ideas?

TIA
 
M

Mark Tangard

Hi Charles,

An AutoText can only record content, not movement, so the short answer is no.
But you could do this with a fairly simple macro

Dim r As Range
If Selection.Start <> Selection.End Then _
MsgBox "Start with nothing selected.": Exit Sub
Set r = Selection.Range
[Template].AutoTextEntries("[autotextname]").Insert _
Where:=Selection.Range, RichText:=True
r.Select
ActiveDocument.Content.Bookmarks(Selection.PreviousBookmarkID + 1).Select

If you have a large number of AutoTexts that need this treatment, you could pass
the AutoText name as a parameter to this macro and have several small (one-line)
macros calling the macro above, to produce each one.

Note: The strange-looking last line (from a post by MVP Jonathan West some time
back) is required in Word 97 or 2000 due to a bug in the line we'd normally use:

Selection.GoTo What:=wdGoToBookmark, Which:=wdGoToNext

If you're using Word 2002 or 2003 the latter may work. Can't check it here.
 

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