JGM
Fri Nov 14 09:11:46 CST 2003
Hi Kathy,
Ah! Now I get it!
> Some time ago, I posted a question on
> microsoft.public.word.vba.userforms, asking the question whether an
> autotext entry could be used to invoke a macro, and didn't get a
> positive reply. If *that* could be done, I'd be very, very happy.
What do you mean? You did get a reply from Steve Lang... I remember even
discussing that reply with him...
In case you cannot find it anymore, here it is:
Quote
Hi Kathy,
It is very possible to do what you are asking (id it all the time!) Here is
an example.
Depending on what characters the user enters before pressing your keyboard
trigger, either a call to display a userform (AmendNACChapter), a sub in a
referenced template, or a regular Autotext entry is run. You'll need to map
the keystroke you want the user to use to call this in the template where
you want to use it.
--------Code to Bind sub to a keystroke (only need to run once against your
template--------------
CustomizationContext = 'path to your template
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro,
KeyCode:=(BuildKeyCode(wdKeyF3)), Command:="doAutoText"
----------------------------------------------------------------------------
--------------------------
------------Hijacked Autotext entry code------------------
Sub doAutotext()
Application.ScreenUpdating = False
Selection.MoveLeft unit:=wdWord, Count:=1, Extend:=wdExtend
On Error GoTo trap
Select Case Selection.Text
Case "ch"
Call AmendNACChapter
Case "s", "S"
With Selection
.Delete unit:=wdCharacter, Count:=-1
.Style = "Normal"
.Style = "Default Paragraph Font"
.Font.Size = 12
Autotext = Drafting.DraftingGlobal.sF3
End With
Case Else
Selection.Range.InsertAutoText
End Select
Selection.Collapse (wdCollapseEnd)
Exit Sub
trap:
MsgBox "Make sure the word immediately preceding the cursor is a
known autotext entry.", vbCritical, "Autotext Error..."
End Sub
------------------------------
HTH and have a great day!
If you have additional questions that the rest of the group may not be
interested in, contact me directly.
--
Steve Lang
Legislative Counsel Bureau
Carson City, NV
GMT+8
slang at lcb hereisadot state anotherdot nv onemoredot us
End Quote
Or, try
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=eqKR6XvoDHA
.2488%40TK2MSFTNGP12.phx.gbl&rnum=2
for the complete thread (I gathered that most of this thread has been
archived...)
(Watch out for the possible hyperlink on 2 lines...)
Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
"Kathy Collingswood" <X@X.net> a écrit dans le message de news:
bbi9rvostao53kprqifl4s73gtjgghj8ot@4ax.com...
> Sorry Jean-Guy, I left out a small, but essential piece of this, but
> thank you for your continuing interest:
>
> A number of the macros from the WP 5.0 DOS past make use of something
> that's like a Basic "Input" statement, where the user, after invoking
> a keystroke macro, "fills in" a series of these, like "Person's Name,"
> "Ward," "Hospital ," "Date of Incarceration" etc. which are presented
> sequentially as the user enters data and presses "Enter" to move on.
> After the last one is filled in, the macro inserts a string like "Mary
> Smith, was admitted to the maternity ward in Portland Hospital on
> 3/12/03."
>
> In order to emulate this, I decided to use a userform (my first),
> wherein the mnemonic- (a word I should have used yesterday instead of
> "acronym," but couldn't remember ... it came to me in a dream last
> night ... which is probably a message from God telling me to change my
> career.) generated macro launches the userform, which contains the
> necessary fields, which can be filled in using the Tab key to advance
> from one to the next. The last tabbed control is an OK key, which,
> upon "Enter" inserts the text in the document. (Again, no need to
> ever leave the keyboard to use the dreaded mouse.)
>
> Some time ago, I posted a question on
> microsoft.public.word.vba.userforms, asking the question whether an
> autotext entry could be used to invoke a macro, and didn't get a
> positive reply. If *that* could be done, I'd be very, very happy.
>
> Any ideas on that ... or any other way to do what I'm attempting?
>
> Regards,
>
> Kathy
>
>
> On Fri, 14 Nov 2003 00:08:23 -0500, "JGM" <no-spam@leaveme.alone>
> wrote:
>
> >Hi Cathy,
> >
> >I still don't get it!
> >Why do you need macros at all if your purpose is to provide the user with
> >shortcuts to insert text?
> >Autotext entries are just the ticket...no?
> >
> >"adb" + Enter or F3 and you get whatever you want... i.e. "attention
deficit
> >high blood pressure disorder" or any other text, table, paragraphs you
care
> >to assign to that shortcut. You can give your autotext entries any name
you
> >want, but as soon as you type the first 3 or 4 characters, a suggestion
pops
> >up and you hit Enter or F3 (F3 will work even if the suggestion does not
pop
> >up...).
> >Just store the autotext in a global template and everyone has acces to
> >them...
> >
> >Finally, it is very easy to train people to manage autotext...
> >
> >Wouldn't that do the trick?
> >Just curious!
> >
> >Cheers!
>