Shift enter mapping

J

jbickel

I created the Macros as Greg suggested but I am having a problem with it
working. These macros were added to a template other than Normal.dot and I
have placed the template in the startup folder. What I am finding is the
first time I open MS Word the macros are not working. If I closed the
initial document and create a new document the macros work. Does anyone know
how I can get it working on the document that opens first?

"I would create a
template with the following macros and use it for documents that you want use
this feature for:

Sub AutoNew()

'Assigns the Macro1 Macro to the ENTER Key
CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
KeyCategory:=wdKeyCategoryMacro, Command:="Macro1"

End Sub
Sub AutoOpen()

'Assigns the Macro1 Macro to the ENTER Key
CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
KeyCategory:=wdKeyCategoryMacro, Command:="Macro1"

End Sub
Sub AutoClose()

CustomizationContext = ActiveDocument.AttachedTemplate
FindKey(KeyCode:=BuildKeyCode(wdKeyReturn)).Disable
'Disables prompt to save template changes
Templates(1).Save

End Sub

Sub Macro1()
'
' Macro1 Macro
' Macro recorded December 1, 2004 by CDR Gregory K. Maxey
'
Selection.TypeText Text:=Chr(11)
End Sub"
 
P

Peter

In order to have the keybinding happen every time Word runs, you need an AutoExec() Sub that mirrors the AutoNew() and AutoOpen() ones. Note that since it's in the Startup folder, the keybinding will apply to ALL documents you open. Hence Greg's suggestion that you use it only for specific documents, and his neglect of AutoExec().

hth,

-Peter
 

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