標題是相當多我想要做一個便攜式的熱鍵,這意味着如果我貼字VBA代碼 我仍然可以使用熱鍵,如Excel的application.onkey
如何在Word VBA中創建hotKey(以編程方式)?
回答
的KeyBindings
對象的東西應該做的問題
訣竅。在這裏看到一個例子:http://www.vbaexpress.com/kb/getarticle.php?kb_id=621
' \\ Code for Module1
Option Explicit
Sub AddKeyBinding()
With Application
' \\ Do customization in THIS document
.CustomizationContext = ThisDocument
' \\ Add keybinding to this document Shorcut: Alt+0
.KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKey0), _
KeyCategory:=wdKeyCategoryCommand, _
Command:="TestKeybinding"
End With
End Sub
' \\ Code for Module2
Option Explicit
' \\ Test sub for keybinding
Sub TestKeybinding()
MsgBox "We have a winner", vbInformation, "Succes"
End Sub
非常感謝!它解決了我的問題結束代碼:函數不能是私人的CustomizationContext = NormalTemplate KeyBindings.Add KeyCode:= BuildKeyCode(Arg1:= wdKeyControl,_ Arg2:= wdKeyT),KeyCategory:= wdKeyCategoryCommand,_ Command:=「funcname」' – Ben
很高興聽到這個工作。不要忘記接受答案。 –
嗨@DaveRook,而不是編輯我的答案,然後向下投票,下次你只是發佈自己的答案?說接受的答案沒有用是不誠實的。 –
- 1. 如何通過模板以編程方式創建Word文檔
- 2. 以編程方式在Word中創建表格
- 3. 如何以編程方式在VBA中創建格式化文本?
- 4. 使用vba以編程方式在模塊中創建表格
- 5. 以編程方式在VBA中創建事件偵聽器
- 6. 如何以編程方式創建UIButton
- 7. 如何以編程方式創建GPO?
- 8. 如何以編程方式創建JPEG
- 9. 如何以編程方式創建DrawerLayout
- 10. 如何以編程方式創建NSPopover
- 11. 如何以編程方式創建SplitView?
- 12. 如何以編程方式創建Tabbar
- 13. 如何以編程方式創建UIViewController?
- 14. 如何以編程方式創建UISplitViewController?
- 15. 如何以編程方式創建CustomCell?
- 16. 如何以編程方式創建UIScrollView?
- 17. 如何以編程方式創建dojox.mobile.TabBar?
- 18. 如何以編程方式創建ProgressBar?
- 19. 如何以編程方式創建UIScrollview
- 20. 如何以編程方式創建UICollectionViewCell
- 21. 如何以編程方式創建NSFetchedPropertyDescription?
- 22. 如何以編程方式創建DSN?
- 23. 如何以編程方式創建BasicHttpBinding?
- 24. 如何以編程方式創建NSTextField?
- 25. 如何以編程方式創建dojo.mobile.view?
- 26. 如何以編程方式創建NSSearchField?
- 27. 如何以編程方式創建TextView?
- 28. 如何以編程方式(使用VBA)在Word中修改圖表2007
- 29. 如何在VBA中使用以編程方式創建的工作表函數
- 30. 如何在android中以編程方式創建方形圖形?
什麼是代碼? – JimmyPena