Home > Software engineering >  Vba automatic adding additional controls to the toolbox
Vba automatic adding additional controls to the toolbox

Time:09-20

Is there any way by VBA statement, to judge whether there is the control of the kit, such as does not exist, it will be automatically added to the control toolbox.

CodePudding user response:

Have this idea???????
Should be impossible...

CodePudding user response:

Guess, use the toolkit will coding, more or less should not know how to add a tool box controls where to find it,
All of this will use to write code to fix them, spend time might as well give them a book or write a description to fix their own,

CodePudding user response:

 if Word.Com mandBars (" custom ".) Controls. Count<1 then 
Normal.ThisDocument.Com mandBars. Item (I). The Name

'this example to create a command bar "Custom", three button is added to the command bar, and then use ActionControl Tag and attribute to determine what is the last click command bar button,

The Set myBar=CommandBars. Add (Name:="Custom", Position:=msoBarTop, Temporary:=True)
The Set buttonOne=myBar. Controls. The Add (Type:=msoControlButton)
With buttonOne
FaceId=133
The Tag="RightArrow
". OnAction="whichButton"
End With
The Set buttonTwo=myBar. Controls. The Add (Type:=msoControlButton)
With buttonTwo
FaceId=134
The Tag="UpArrow"
. OnAction="whichButton"
End With
The Set buttonThree=myBar. Controls. The Add (Type:=msoControlButton)
With buttonThree
FaceId=135
The Tag="DownArrow
". OnAction="whichButton"
End With
MyBar. Visible=True
'whichButton subroutine response OnAction method and determine the final which a command bar button, click

Sub whichButton ()
The Select Case CommandBars. ActionControl. The Tag
Case "RightArrow
"MsgBox (" Right Arrow button clicked. ")
Case "UpArrow"
MsgBox (" the Up Arrow button clicked. ")
Case "DownArrow
"MsgBox (" the Down Arrow button clicked. ")
End the Select
End Sub
  •  Tags:  
  • VBA
  • Related