View Single Post
  #4   Report Post  
Posted to microsoft.public.word.newusers
Cindy M. Cindy M. is offline
external usenet poster
 
Posts: 2,416
Default Word 2003 - F1 and macros

Hi Tom,

I don't think this is unique to Word 2003 (I noticed the same thing in Word
2000) - but why can't the F1 key be used for a macro instead of to bring up
Help? Does anyone know - or IS there in fact a way to assign F1 to execute
a macro?

There is, but it requires a macro. The basic code is as follows. Note the
CustomizationContext: you need to set this to where you want the assignment
to be valid.


I want the assignment to be globally available to all documents and
templates.

"TestWord" is the name of the macro.

Application.CustomizationContext = ActiveDocument
Application.KeyBindings.Add wdKeyCategoryMacro, "TestWord", wdKeyF1


I opened normal.dot, created a macro called Autoexec, and copied your code
into that macro.

When I ran the autoexec manually, I got the following:

Run-time error 5346
Word cannot change the function of the specified key.


I then closed Word and restarted it. Now every time I open word, I get the
following:

Run-time error 4248
This command is not available because no document is open.

I then created a macro called "TestWord" and copied your code into that
macro. I then ran the macro and got no errors.

I started to record a macro, but Word would still not let me use the F1
key.

Color me confused,

First, you need to create the macro to which you want to assign the keyboard
shortcut. Make sure it's in Normal.dot Then you put that macro name in place of
TestWord.

Replace ActiveDocument with: NormalTemplate

Now make sure the insertion point is blinking in the "Sub" and press F5 to
execute it. You only need to run it the one time. After that, F1 will always
execute the macro (until you loose Normal.dot, anyway).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)