Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-05-2013, 03:39 PM
PosseJohn PosseJohn is offline Need Help With How To Use KeyBindings Windows XP Need Help With How To Use KeyBindings Office 2007
Novice
Need Help With How To Use KeyBindings
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default Need Help With How To Use KeyBindings

I have a document that has Fields for the user to edit. One of the things I've found useful is to capture when the user presses "Enter" and run some code:

On Document_Open I have the following:

Code:
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro"
The EnterKeyMacro is:

Code:
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
    End If
End Sub
This seems to work just fine in the document it was intended for, BUT if you have another Word document open, pressing ENTER results in no action (nothing happens).

How can I get the 'other' document to respond to the keypress of ENTER?

Thanks!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With How To Use KeyBindings KeyBindings in PowerPoint? tinfanide PowerPoint 1 03-16-2013 10:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft