Can do a simple check like this. But an xls not in use by excel might be in use by other application. That is out of the scope of such check.
[tt]
xlsspec="d:\abc\xyz.xls" 'your input
if bxls_inuse(xslspec) then
wscript.echo "The xls file : " & xlsspec & " is in use."
else
wscript.echo "The (xls) file : " & xlsspec & " is not in use (by excel) if exists."
end if
function bxls_inuse(spath)
bxls_inuse=false
dim bexists : bexists=true
dim oxl
on error resume next
set oxl=getobject(,"excel.application")
if err.number<>0 then
err.clear
bexists=false
end if
on error goto 0
if bexists then
for each owkbk in oxl.workbooks
if lcase(owkbk.fullname)=lcase(spath) then
bxls_inuse=true
exit for
end if
next
end if
end function
[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.