View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Check if workbook open

You could use a function like

Option Compare Text

Function IsWorkbookOpen(FileName As String) As Boolean
Dim WB As Workbook
For Each WB In Workbooks
If WB.Name = FileName Or _
WB.FullName = FileName Then
IsWorkbookOpen = True
Exit Function
End If
Next WB
IsWorkbookOpen = False
End Function


Then call this in your code

If IsWorkbookOpen("Book2.xls") = False Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"dkipping"
wrote in
message
...

Some macros I use require another workbook to open so I include
a line
like Workbooks.Open Filename:= C:\My\
Documents\Orders\POTemp.xls
The problem occurs when that workbook is already open - the
macro
stalls. Is there a way to bypass that instruction if the other
workbook is already open?


--
dkipping
------------------------------------------------------------------------
dkipping's Profile:
http://www.excelforum.com/member.php...o&userid=34683
View this thread:
http://www.excelforum.com/showthread...hreadid=544484