Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asigning shortcut to Word macro 1

Status
Not open for further replies.

Loomah

Technical User
Mar 4, 2002
1,911
IE
Hello all
I'm not a big Word user but I seem to be using it more and more (not for anything spectacular!) However, I still fall into the trap of trying to switch windows using CTRL+TAB, as in Excel. This doesn't work!

So I've written the code to do the work but I can't seem to assign the code to the CTRL+TAB key combination.

Does anyone know if this is possible and if so how can I do it (in xl2k)??

Happy Friday, Off to the pub
;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Loomah,

The following should do the trick: Insert the listed procedures into a Code Module. Run Sub TrapCtrlTab once. Close the document containing these procedures (save for future use). Exit Word; you will be prompted to save changes to "Normal.dot". Select Yes. The next time you open Word and multiple docs you can cycle through them by pressing Ctrl-Tab. To remove this action, run Sub ReleaseCtrlTab.

Good Luck!

M. Smith


Code:
Sub TrapCtrlTab()
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyTab), _
    KeyCategory:=wdKeyCategoryMacro, Command:="NextWindow"

End Sub


Sub NextWindow()
  If ActiveWindow.Index = Documents.Count Then
    Windows(1).Activate
  Else
    Windows(ActiveWindow.Index + 1).Activate
  End If
End Sub


Sub ReleaseCtrlTab()
  CustomizationContext = NormalTemplate
  FindKey(BuildKeyCode(wdKeyControl, wdKeyTab)).Clear
End Sub
 
Mike
That's excellent!! I'm now going to have a look at how it works and what it means - it's all about learning for me!

Cheers
;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top