View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
MMesarch MMesarch is offline
external usenet poster
 
Posts: 7
Default Checking if Workbook is Open

Harald and Sebastien, Thanks that did the trick
--
Mark Mesarch
School of Natural Resources
University of Nebraska-Lincoln


"Harald Staff" wrote:

Hi Mark

Function IsOpen(sName As String) As Boolean
On Error Resume Next
IsOpen = Len(Workbooks(sName).Name)
End Function

Sub test()
MsgBox IsOpen("Book2.xls")
End Sub

HTH. Best wishes Harald

"MMesarch" skrev i melding
...
Hi,
I have a workbook that is a template for charting data selected from

another
workbook. The other workbook might be one of several different ones so I

do
not want to link to any one specific workbook.

I have a macro that pulls a subsection of data from the other workbook

into
the charting workbook.

When the macro begins I want test to see if the other workbook open is
already open. If it is then the macro proceeds and pulls int he data. It
the workbook is not open then I want that workbook to open.

How do I test to see if a workbook is open in the application? If the
result could be a boolean then I could use and IF statement to do the test
and decide whether to open the worksheet.
Thanks.

--
Mark Mesarch
School of Natural Resources
University of Nebraska-Lincoln