Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I have a document that I have created exit macros for to set tab order and
another macro to force the enter key to function as the tab key but when I use the mouse to click in a field, it tabs to the next field also. I need to be able to click in any field and then be able to tab through the document from there using the original tab order. This document must be locked down in this manner or it won't work for us the way we need it to. Any assistance would be appreciated. Here's a copy of some of the macro's I've used, one for the tab order and ther rest for the enter key to function as the tab key: Sub Accent() ' ' Accent Macro ' Macro created 11/18/2009 by tgutz ' Selection.GoTo What:=wdGoToBookmark, Name:="Direction" End Sub 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.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 | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Issue uploading macro enabled Excel to Sharepoint(xlsm using xla) | Excel Discussion (Misc queries) | |||
MS Excel Macro issue | Excel Discussion (Misc queries) | |||
Doing MS Training in Excel, having Macro Issue | Excel Discussion (Misc queries) | |||
Excel Macro- sort issue in Excel2003 | Excel Worksheet Functions | |||
Excel 2007 Macro/Link Issue (apologies for cross-posting) | Links and Linking in Excel |