我有一个Userform来创建流程图。如何使用commandbutton1
重复插入形状并在等距位置移动框,即。如何重复if statements
直到commandbutton1
被按下?
此代码仅选择第一个形状,我想在点击cmdbutton1
时插入形状。
Sub CommandButton1_Click()
If OptionButton1 = True Then
Sheets("Sheet2").Select
ActiveSheet.Shapes.AddShape(1, 68, 99, 136, 57).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Me.TextBox1.Value
Selection.ShapeRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
UserForm1.TextBox1.Value = ""
ElseIf OptionButton2 = True Then
Sheets("Sheet2").Select
ActiveSheet.Shapes.AddShape(9, 68, 99, 136, 57).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Me.TextBox1.Value
Selection.ShapeRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
UserForm1.TextBox1.Value = ""
ElseIf OptionButton3 = True Then
Sheets("Sheet2").Select
ActiveSheet.Shapes.AddShape(2, 68, 99, 136, 57).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Me.TextBox1.Value
Selection.ShapeRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
UserForm1.TextBox1.Value = ""
End If
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 135.75, 120, 135.5, 165).Select
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadTriangle
End Sub