Enter Key Macro - WORD 2003

G

Gina

I've read the responses on how to force the enter key to act as a tab key in
a form(http://support.microsoft.com/?kbid=211219). But for someone who has
never created a MACRO before, it's all Greek to me. First, which macro on
this website do I need to use? And is there a website that lists step by
step directions on how to create the macro?

Thanking you in advance.
 
G

Gina

I've tried several times to create the MACRO. All 4 are in my form exactly
as they appear on the support website. It's not working. My ENTER key is
still acting like an ENTER key, rather than a TAB key. Any ideas on what I
may be doing wrong?
 
S

Suzanne S. Barnhill

I'm afraid not, as I have no VBA expertise and little experience with forms.
But undoubtedly someone else here will be able to help. Graham?
 
G

Graham Mayor

The process is intended to work with an *unprotected form template.*
Open the form template.
Press ALT+F8
In the ensuing dialog the third window is entitled 'macros in'. In that
dialog pick the name of your form template.
In the top window type Autonew and click the Create button on the right.
The vba editor will open at the right place with four lines of code similar
to

Sub Autonew()
'
' Autonew Macro
' Macro created 13/09/2008 by Gina
'

End Sub

and the cursor will be flashing in the space above 'End Sub'
Select all the lines.
Open the web page http://support.microsoft.com/?kbid=211219
and copy the first of the four macros to replace the selected lines.
Copy the other three macros one at a time after this macro.
You should now have four macros that will look something like that below
(copy them from the web page rather than from here to avoid problems with
prematurely broken lines that will add another layer of problem for you to
work out)
Close the vba editor and return to the form
Ensure that the form is NOT protected and save it.
Create a new document from the template.
The macro will change the behaviour of the enter key and lock the form.
allowing it to be used.

Sub EnterKeyMacro()
' Check whether the document is protected for forms
' and whether the protection is active.
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _
Selection.Sections(1).ProtectedForForms = True Then
' Retrieve the bookmark of the current selection.
' This is equivalent to the name of the form field.
myformfield = Selection.Bookmarks(1).Name
' Go to the next form field if the current form field
' is not the last one in the document.
If ActiveDocument.FormFields(myformfield).Name <> _
ActiveDocument.FormFields(ActiveDocument.FormFields.Count) _
.Name Then
ActiveDocument.FormFields(myformfield).Next.Select
Else
' If the current form field is the last one,
' go to the first form field in the document.
ActiveDocument.FormFields(1).Select
End If
Else
' If the document is not protected for forms,
' insert a tab stop character.
Selection.TypeText Chr(13)
End If
End Sub
Sub AutoNew()
' Do Not protect the template containing these macros.
CustomizationContext = ActiveDocument.AttachedTemplate
' Bind the ENTER key to the EnterKeyMacro.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
KeyCategory:=wdKeyCategoryMacro, _
Command:="EnterKeyMacro"
' Reprotect the document with Forms protection.
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
Sub AutoOpen()
' This macro will reassign the ENTER key when you open an existing
' Word form fields document.
CustomizationContext = ActiveDocument.AttachedTemplate
' Bind the Enter key to the EnterKeyMacro.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro"
End Sub
Sub AutoClose()
CustomizationContext = ActiveDocument.AttachedTemplate
FindKey(KeyCode:=BuildKeyCode(wdKeyReturn)).Disable
' Disables prompt to save template changes.
Templates(1).Save
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Copy the four macros to the vba editor
 

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