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