以下是引用wfstuman在2006-10-28 20:01:37的发言:我们知道对于自定义的菜单可以通过OnAction属性来制定单击次菜单所触发的过程,语法如下: .OnAction = "mySub" 但是如果mySub有参数,那么应该怎么写呢? 可以变通一下,如: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2006-12-3 17:20:33 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0112^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Private WithEvents myComBox As Office.CommandBarComboBox Sub Example() Word.CustomizationContext = ActiveDocument Set myComBox = Word.CommandBars("Standard").Controls.Add(Type:=msoControlComboBox, Before:=1) With myComBox .AddItem "One", 1 .AddItem "Two", 2 .AddItem "Three", 3 End With End Sub '----------------------
Sub Test(N As Byte) Select Case N Case 1 MsgBox "A" Case 2 MsgBox "B" Case 3 MsgBox "C" End Select End Sub '----------------------
Private Sub myComBox_Change(ByVal Ctrl As Office.CommandBarComboBox) Call Test(myComBox.ListIndex) End Sub '----------------------
|