#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default syntax

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA syntax dhstein Excel Discussion (Misc queries) 3 March 13th 09 12:53 PM
Syntax HELP Eric H Excel Discussion (Misc queries) 4 August 30th 08 01:30 AM
IRR Syntax Bruce Excel Worksheet Functions 1 July 13th 07 09:02 PM
Help with Syntax Steve Excel Discussion (Misc queries) 2 June 21st 07 06:52 PM
Syntax Help Dmorri254 Excel Worksheet Functions 2 March 2nd 05 02:51 PM


All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"