我用vb编了一段程序,调试时总是提示提示的是这句对象变量或with块未设置,不知怎么解决,请高手们指教. 25

程序:DimswappAsSldWorks.SldWorksDimnewswappAsSldWorks.SldWorksDimpartAsModelDoc2Dimbool... 程序:Dim swapp As SldWorks.SldWorks
Dim newswapp As SldWorks.SldWorks
Dim part As ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Configuration As Object
Dim hz As String
Dim pth As String
Dim path As String
Dim guige As String
Dim value As Object
Dim lujing As String
Dim newpart As String
Dim zlen, ftype, fpath, fname
Dim asm1 As Object
Private Sub Command1_Click()
摆动压板.Hide
Dim model As ModelDoc2
Set swapp = CreateObject("sldworks.application")
Set newswapp = CreateObject("sldworks.application")
Set asm1 = swapp.ActiveDoc
swapp.Visible = True
If asm1 Is Nothing Then
MsgBox ("当前文件是空文件,需要先打开一个装配体并存盘!")

Else
ftype = asm1.GetType
If ftype <> 2 Then
MsgBox ("当前文件不是装配体文件,请新建一个装配体并存盘!")
Else
fpath = asm1.GetPathName
If fpath = "" Then
MsgBox ("请先保存文件!")
Else
fpath = asm1.GetPathName
'Debug.Print fpath
zlen = Len(fpath)
For i = zlen To 1 Step -1
If Mid(fpath, i, 1) = "\" Then
fname = Mid(fpath, 1, i - 1)
'Debug.Print ("父目录名:" + fname)
Exit For
End If
Next i

guige = "摆动压板1"
pth = App.path & "/res/摆动压板1.sldprt"
Set part = newswapp.OpenDoc4(pth, 1, 0, guige, longstatus)
Set part = newswapp.ActivateDoc("摆动压板1")
part.Visible = False(提示的是这句对象变量或with块未设置)
hz = ".sldprt"
lujing = fname + "\" + guige + hz
part.SaveAs2 lujing, 0, False, False
asm1.AddComponent4 lujing, guige, 0, 0, 0
'Set part = Nothing
newswapp.CloseDoc "guige+hz"
End If
End If
End If
End Sub
现在调试不出错了,可是生成exe后还是报91错误?
展开
 我来答
庹灵波PG
2011-05-11 · TA获得超过233个赞
知道答主
回答量:378
采纳率:0%
帮助的人:0
展开全部
要加一句Set rst=new ADODB.Recordset,如下

Dim rst As ADODB.Recordset
Set rst=new ADODB.Recordset
Dim rights As String
Dim sTokens() As String
Dim msg As String
'查找权限
SQl = "select 权限 from 用户信息表 where 用户ID=' " & UserID & " ' "
Set rst = SelectSQL(SQl, msg)
If rst.RecordCount > 0 Then
rights = Trim(rst.Fields(0))
rst.Close
Else
MsgBox ("没有用户信息!")
Exit Sub
End If
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式