Check file open status

K

kaon

Hi all,

I have written a macro to do cell copying from a xls to another xls, i
the marco I used .getopenfilename to open a file, but I do not want t
open the file again if it is already opened. So how can I check th
file open status?

Thanks
 
V

Vasant Nanavati

On Error Resume Next
Set wb = Workbooks("MyWorkbook.xls")
On Error GoTo 0
If wb Is Nothing Then
'open it
Else
'already open
End If
 
K

kaon

Thanks.

Now what I concern now is the error statement. I have previousl
declared one already, how can I resume the error statement afte
executing the piece of code above?


Code I wrote:

On Error GoTo EOS
Set abcWks = ThisWorkbook.ActiveSheet
fName = Application.GetOpenFilename(FileFilter:="All files (*.*)
*.*", _
Title:="Select a file"
MultiSelect:=False)
If fName = "False" Then
Exit Sub
Else: Set xyzWkbk = Workbooks.Open(Filename:=fName)
End I
 
Top