Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Word, Form Fields, and the Enter Key
I've posted once on this subject, with no reply. I thought I'd try
again in a different format. I'm using the code below to act like the Tab Key to go between Form Fields. The problem is that when using the Enter Key, the Form Fields are not Formatted, as they are with the Tab Key. Please, someone copy this code into a blank worksheet and try it yourself, format some Form Fields, and tell me why the code is not formatting the Form Fields. By the way, after using the Enter Key, if I go back to the previous Form Field by using the left arrow or mouse, for example and then exit the Form Field with a right arrow or Tab Key, the Field will then show the proper formatting. Thanks for your help, Bernie The code below was copied from he http://support.microsoft.com/kb/211219 Sub EnterKeyMacro() Dim myformfield ' 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.FormField s.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)).Disabl e ' Disables prompt to save template changes. Templates(1).Save End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I would like to enter text into fields on a form.... | Microsoft Word Help | |||
form fields keep inserting spaces when you enter data on form ? | Page Layout | |||
Is there a way to enter pictures into form fields? | Microsoft Word Help | |||
cannot enter into form fields | Microsoft Word Help | |||
How do I replicate form fields in Word so that when you enter one. | Microsoft Word Help |