如题所述
第1个回答 2011-10-17
Sub shiyan()
On Error GoTo handerr:
StrSheet = "C:\5月考勤记录.xls"
StrSheet = Dir(StrSheet, vbDirectory)
If StrSheet = "" Then
MsgBox "目标表不存在!"
Else
MsgBox "工作表存在。"
End If
Set theBook = Application.Workbooks(StrSheet)
MsgBox StrSheet & " 已经打开"
Exit Sub
handerr:
MsgBox StrSheet & " 未打开"
End Sub
On Error GoTo handerr:
StrSheet = "C:\5月考勤记录.xls"
StrSheet = Dir(StrSheet, vbDirectory)
If StrSheet = "" Then
MsgBox "目标表不存在!"
Else
MsgBox "工作表存在。"
End If
Set theBook = Application.Workbooks(StrSheet)
MsgBox StrSheet & " 已经打开"
Exit Sub
handerr:
MsgBox StrSheet & " 未打开"
End Sub
第2个回答 2011-10-13
for each workbook0 in Application.Workbooks
'判断 workbook0.Name
next本回答被提问者采纳
'判断 workbook0.Name
next本回答被提问者采纳
第3个回答 2011-10-13
网友“snddd2000”的答案只能用于判断是否打开了,不能判断是否存在啊!