以下是文本格式的代码,以防图像未加载:
Sub CommandButton1_Click()
Dim NoIO As String
Dim shp1 As Visio.Shape
NoIO = ComboBox1.Value
If NoIO = "7" Then
MsgBox shp1.ID
'Call test(shp1)'
'Target shape id selected'
'Change shape data of that shape'
End If
Unload Me
End Sub
每当我尝试输出形状的ID时,都会出现错误:
对象变量或未设置块变量
由于过程声明不匹配,因此无法更改子例程的参数,因为此代码在用户窗体上单击按钮后运行。
答案 0 :(得分:0)
您尚未初始化形状shp1
。您尚未说明如何选择形状或为什么要选择形状,因此我在下面提供了一个简单的示例。
Sub CommandButton1_Click()
Dim NoIO As String
Dim shp1 As Visio.Shape
NoIO = ComboBox1.Value
Set shp1 = Application.ActivePage.Shapes(1) ' Example only!
If NoIO = "7" Then
MsgBox shp1.ID
End If
Unload Me
End Sub