View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Lavedas Tom Lavedas is offline
external usenet poster
 
Posts: 7
Default I need "On Error" help

Since trying to open an already open workbook does NOT throw an error, it can't be trapped with an On Error statement. Rather, the condition is best handled by directly testing for the open book, something like this ...

For Each WB In Workbooks
bWBOpen = (StrComp(wb.FullName, "F:\book1.xls", vbTextCompare) = 1)
If bWBOpen Then
Set SourceWB = WB
Exit For
End If
Next
If Not bWBOpen Then Set SourceWB = Workbooks.Open("F:\book1.xls")

Tom Lavedas
===========


"GregJG " wrote:

I use this code to open a workbook

Set SourceWb = Workbooks.Open("f:\book1.xls")

but, if the workbook is already open, I'm guessing I would need to use
an "on error resume next"

But everything I have tried is not working.

can someone help?


---
Message posted from http://www.ExcelForum.com/