syntax

L

libby ~xl97

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top