dim shtname as worksheet
set shtname = xlsapp.Workbooks(Kitting.WO.text & "-" & Sdept(n) & ".xls").sheets(ModSeled(t))
'这段代码有误
'e.g.: Kitting.WO.text & "-" & Sdept(n) & ".xls" = "123456-TE50.xls" ModSeled(t) = "LPT 50X"
If IsNull(shtname)=False then '这里无法判断
...
end if
如上面所示代码出现问题,求教各位帮忙解决。
3 个解决方案
#1
On Error Resume Next
Dim shtname As Worksheet
Set shtname = Nothing
Set shtname = xlsapp.Workbooks(Kitting.WO.Text & "-" & Sdept(n) & ".xls").Sheets(ModSeled(t))
'这段代码有误
'e.g.: Kitting.WO.text & "-" & Sdept(n) & ".xls" = "123456-TE50.xls" ModSeled(t) = "LPT 50X"
If shtname Is Nothing Then '这里无法判断
MsgBox ("Sheets:" & ModSeled(t) & "不存在")
End If
#2
但是我是用来判断存在的哦,不是判断不存在。
#3
解决了,谢谢你!
#1
On Error Resume Next
Dim shtname As Worksheet
Set shtname = Nothing
Set shtname = xlsapp.Workbooks(Kitting.WO.Text & "-" & Sdept(n) & ".xls").Sheets(ModSeled(t))
'这段代码有误
'e.g.: Kitting.WO.text & "-" & Sdept(n) & ".xls" = "123456-TE50.xls" ModSeled(t) = "LPT 50X"
If shtname Is Nothing Then '这里无法判断
MsgBox ("Sheets:" & ModSeled(t) & "不存在")
End If
#2
但是我是用来判断存在的哦,不是判断不存在。
#3
解决了,谢谢你!