Insert two autotext entries?

D

Dawn Rhoads

I am trying to take a fill-in field (or maybe have the user click a button a
toolbar and pop up a dialog box), have the user type an autotext shortcut,
and then based on that shortcut choose the two correct entries to insert at
two different bookmark locations. I'm no programmer, so I can record and
manipulate macros, but don't know how to write them. See below for the macro
I've managed to record that will insert the two entries at two bookmarked
locations. Two problems with this code:

- I have no idea how to get it to accept the user's input as to which
autotext to use. This code just inserts the two autotext entries specified
in the code itself. The way the autotext shortcuts work is that I will
select a set of initals and the specific entries would be those initials with
either an "s" or a "c" appended at the end of the shortcut. So, if I type
"alw" the two shortcuts needed would be alws and alwc. If I type dpp, the
two shortcuts would be dpps and dppc. I'm hoping if the user types the three
initials, the macro can take over and "know" which two autotext shortcuts it
should be using.

- the autotext entries I need to use are stored in a document that we save
in our startup folder, so all the users share it and are able to access our
"system wide" autotext entries from it. However, this macro only seems to
work with autotext entries that are in my own Normal template. Any shortcut
that I try to use from our shared document returns an error saying that the
"requested member of the collection does not exist".

We could just put in two fill-in fields and have the users type the
appropriate shortcuts in each place, however I am hoping to use a macro to
help assure that the two entries inserted are always for the same person (so
we can't accidently put in contact info block for one person and put in a
signature block for another person.)

Am I trying to do the impossible or obscenely complicated here? Any ideas
anyone has would be greatly appreciated. Thanks for your time!

Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
ActiveDocument.AttachedTemplate.AutoTextEntries("alws").Insert Where:= _
Selection.Range, RichText:=True
Selection.GoTo What:=wdGoToBookmark, Name:="Text2"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
NormalTemplate.AutoTextEntries("dppc").Insert Where:=Selection.Range, _
RichText:=True

--Dawn Rhoads
 

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