在使用Excel VBA的过程中,如何判断某个Excel文件是否打开?
示例:
Dim sFileName as String
Dim i as Integer
Dim bOpenFlag as boolean
bOpenFlag=False
sFileName="aaa.xlsx"
for i in Workbooks.Count
if sFileName=Workbooks(i).Name then
bOpenFlag=True
exit for
end if
next
if bOpenFlag=True then
msgbox "文件已打开",vbOkonly,"信息提示"
else
msgbox "文件未打开",vbOkonly,"信息提示"
end if