Hello,

Is there any way to get an autotext entry to execute a macro? In other
words, I'd like to create an autotext entry that when the user gets the
pop-up to press enter, that when they do, it executes a macro. I'm pretty
sure there is no way to do this but I just thought I'd ask to be sure. I'm
using Office 2003 but 2007 available.

Thanks,
Peter

Re: Macro execution by Autotext entry by Jay

Jay
Tue May 13 08:05:03 PDT 2008

Peter wrote:
> Hello,
>
> Is there any way to get an autotext entry to execute a macro? In other
> words, I'd like to create an autotext entry that when the user gets
> the pop-up to press enter, that when they do, it executes a macro.
> I'm pretty sure there is no way to do this but I just thought I'd ask
> to be sure. I'm using Office 2003 but 2007 available.
>
> Thanks,
> Peter

You're right, that isn't going to work.

I think the closest you'll get is to include a MacroButton field in the
autotext result, which the user can click after the entry is inserted to run
the macro.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.



Re: Macro execution by Autotext entry by Jonathan

Jonathan
Tue May 13 08:17:00 PDT 2008


"Peter" <Peter@discussions.microsoft.com> wrote in message
news:202507E6-CFA1-42C1-916E-BB7F655B0F9C@microsoft.com...
> Hello,
>
> Is there any way to get an autotext entry to execute a macro? In other
> words, I'd like to create an autotext entry that when the user gets the
> pop-up to press enter, that when they do, it executes a macro. I'm pretty
> sure there is no way to do this but I just thought I'd ask to be sure. I'm
> using Office 2003 but 2007 available.
>

It is possible to assign Enter as a shortcut key to a macro. You can't do it
through the Tools customize dialog, but you can do it in VBA using the
KeyBindings collection.

So, what you can do is have the macro insert the autotext entry and then do
whatever code you want after that.

However, if you are going to do this, you need to be VERY careful how you
write the macro, since it will be run every time you press Enter whether or
not the AutoComplete tooltip is showing, which means you have to get the
macro to do everything Word normally does when you press Enter. There are a
surprisingly large number of conditions that need to be addressed.

This isn't impossible, but it is a tough task. Unless you really feel you
must go this route, I would recommend you make inserting the AutoText and
running the subsequent macro as two separate actions.

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



Re: Macro execution by Autotext entry by fumei

fumei
Tue May 13 09:25:46 PDT 2008

An excellent response Jonathan.

Just to add my voice. AutoText entries are not, in themselves, executable.
They are the results of an action (inserting them), not actions themselves.
Yes, you could put a MACROBUTTON into one, so the user could execute
something with that. But inserting an AutoText itself will not execute
anything.

Yes, you can do things with the Enter key, but I would concur with Jonathan
that doing this requires careful thought and consideration.

Why not go another route? One macro that inserts the AutoText, then does
whatever else.

Jonathan West wrote:
>> Hello,
>>
>[quoted text clipped - 3 lines]
>> sure there is no way to do this but I just thought I'd ask to be sure. I'm
>> using Office 2003 but 2007 available.
>
>It is possible to assign Enter as a shortcut key to a macro. You can't do it
>through the Tools customize dialog, but you can do it in VBA using the
>KeyBindings collection.
>
>So, what you can do is have the macro insert the autotext entry and then do
>whatever code you want after that.
>
>However, if you are going to do this, you need to be VERY careful how you
>write the macro, since it will be run every time you press Enter whether or
>not the AutoComplete tooltip is showing, which means you have to get the
>macro to do everything Word normally does when you press Enter. There are a
>surprisingly large number of conditions that need to be addressed.
>
>This isn't impossible, but it is a tough task. Unless you really feel you
>must go this route, I would recommend you make inserting the AutoText and
>running the subsequent macro as two separate actions.
>

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200805/1