deactivate enter key in protected sections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know we can reporgram [Enter] to function as a [Tab] in a form but I want
to deactivate it all together within a 'form' protected section - is this
possible and what might the ramifications be?

MervB
:-)
 
I know we can reporgram [Enter] to function as a [Tab] in a form but I want
to deactivate it all together within a 'form' protected section - is this
possible and what might the ramifications be?

MervB
:-)

Hi Merv,

Use the macros in http://support.microsoft.com/?kbid=211219 but cut
down the first one like this:

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
' Leave out the part that moves to the next field
Else
' If the document is not protected for forms,
' insert a tab stop character.
Selection.TypeText Chr(13)
End If
End Sub

I haven't done any testing with this, but it doesn't appear to have
any nasty side effects. If the cursor is in a document that isn't
protected for forms, or it's in a nonprotected section of a partially
protected document, the Enter key will behave normally. If it's in a
field in a protected section of a forms document, then it will be a
dead key.

BTW, this question would have been more appropriate in one of the VBA
programming newsgroups.
 
Thanks Jay,

Sounds just what I'm looking for - Have taken note of your comment regarding
being more appropriate for the VBA programming newsgroups.



Jay Freedman said:
I know we can reporgram [Enter] to function as a [Tab] in a form but I want
to deactivate it all together within a 'form' protected section - is this
possible and what might the ramifications be?

MervB
:-)

Hi Merv,

Use the macros in http://support.microsoft.com/?kbid=211219 but cut
down the first one like this:

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
' Leave out the part that moves to the next field
Else
' If the document is not protected for forms,
' insert a tab stop character.
Selection.TypeText Chr(13)
End If
End Sub

I haven't done any testing with this, but it doesn't appear to have
any nasty side effects. If the cursor is in a document that isn't
protected for forms, or it's in a nonprotected section of a partially
protected document, the Enter key will behave normally. If it's in a
field in a protected section of a forms document, then it will be a
dead key.

BTW, this question would have been more appropriate in one of the VBA
programming newsgroups.
 

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

Back
Top