Microsoft Office Tutorials and References
In Depth Information
Forms: Suppressing New Paragraphs in Form Fields
Option explicit¶
' * * * * *¶
Sub ActivateKeyAssignmentsInCurrentFile()¶
' Changes the key assignments for the document¶
' or template which is active when the macro is run!¶
' To return the file to default Word behavior¶
' run the macro DeactivateEnterAndNewLineKeyAssignments¶
CustomizationContext = ActiveDocument¶
' Assign the DisableEnterKeyInFormFields macro¶
' to the Enter key for this document¶
KeyBindings.Add KeyCode:=wdKeyReturn, _¶
KeyCategory:=wdKeyCategoryMacro,
Command:="DisableEnterKeyInFormFields"¶
' Assign the DisableNewLineInFormFields macro¶
' to the Shift+Enter key combintation in this document¶
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyShift, wdKeyReturn), _¶
KeyCategory:=wdKeyCategoryMacro,
Command:="DisableNewLineInFormFields"¶
End Sub¶
' * * * * *¶
Sub DisableEnterKeyInFormFields()¶
' Check whether the document is protected for forms¶
' and whether the protection is active in the current section.¶
' If insertion point is not in a protected section¶
' or a form field, allow new paragraphs to be inserted¶
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _¶
Selection.Sections(1).ProtectedForForms Then¶
Exit Sub¶
End If¶
Selection.TypeText Chr$(13)¶
End Sub¶
' * * * * *¶
Sub DisableNewLineInFormFields()¶
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _¶
Selection.Sections(1).ProtectedForForms Then¶
Exit Sub¶
End If¶
Selection.TypeText Chr$(11)¶
End Sub¶
' * * * * *¶
Sub DeactivateEnterAndNewLineKeyAssignments()¶
CustomizationContext = ActiveDocument¶
FindKey(BuildKeyCode(wdKeyReturn)).Clear¶
FindKey(BuildKeyCode(wdKeyShift, wdKeyReturn)).Clear¶
End Sub¶
Wrd
Search JabSto ::




Custom Search