实时错误91,对象变量或with块变量未设置~~如何解决
Private Sub Command1_Click()Dim part As Object
Dim strfilename As String
Dim longstatus As Long
Dim d1 As Integer
Dim d2 As Integer
Dim h As Single
If Dir(strfilename) = "" Then
MsgBox ("文件不存在,请检查路径:" & vbCrLf & strfilename)
Exit Sub
End If
strfilename = App.Path + "\" + "垫圈.sldprt"
Set swApp = CreateObject("sldworks.application")
swApp.Visible = True
Set part = swApp.opendoc4(strfilename, 1, 0, "", longstatus)
Set part = swApp.ActivateDoc("垫圈")
ProgressBar1.Value = 4
d1 = Text1.Text
d2 = Text2.Text
h = Text3.Text
Debug.Print d1, d2, h
strfilename = "@垫圈.sldprt"
part.Parameter("d1 @ 草图2 " & strfilename).SystemValue = d1 / 1000
part.Parameter("d2 @ 草图2 " & strfilename).SystemValue = d2 / 1000
part.Parameter("h @ 拉伸1 " & strfilename).SystemValue = h / 1000
part.EditRebulid
ProgressBar1.Value = 9
Set part = Nothing
Set swApp = Nothing
ProgressBar1.Value = 100
StatusBar1.Panels(1).Text = "更新结束"
End Sub
在最后 part.Parameter("d1 @ 草图2 " & strfilename).SystemValue = d1 / 1000~~~调试时就会出现实时错误91,对象变量或with块变量未设置,有大神告诉怎么解决吗?