Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
iamnu iamnu is offline
external usenet poster
 
Posts: 8
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I would like to enter text into fields on a form.... mgh Microsoft Word Help 1 February 29th 08 05:40 AM
form fields keep inserting spaces when you enter data on form ? JKnapp Page Layout 1 December 28th 07 01:40 PM
Is there a way to enter pictures into form fields? Joaquin Hernandez Microsoft Word Help 2 January 24th 06 09:55 PM
cannot enter into form fields desperate secretary Microsoft Word Help 1 August 18th 05 05:46 AM
How do I replicate form fields in Word so that when you enter one. Lorna Walker Microsoft Word Help 1 February 15th 05 02:41 PM


All times are GMT +1. The time now is 07:24 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"