syntax
Try a loop looking for the name
as in
if Workbooks(I).Name = Results
or similar
The alternative is to trap an error condition by using
Workbooks("Results")
Will give subscript out of range if it doesn't exist.
Unless you are trying to check for the existance of a file
on a drive ? In which case use the Files Collection.
Following as modified from the help file
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("C:\")
Set fc = f.Files
For Each f1 In fc
s = f1.Name
s = s & vbCrLf
MsgBox s
Next
-----Original Message-----
Hi
Does anybody know what the syntax is for this:
I want an if statement that says
If Workbook(Results.xls) is open then
call a macro
else
do something else
end if
It's getting it to check whether the workbook Results.xls
is open and returning a true or false.
Thanks in advance
Libby
.
|