Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA syntax | Excel Discussion (Misc queries) | |||
Syntax HELP | Excel Discussion (Misc queries) | |||
IRR Syntax | Excel Worksheet Functions | |||
Help with Syntax | Excel Discussion (Misc queries) | |||
Syntax Help | Excel Worksheet Functions |