Check file open status

  • Thread starter Thread starter kaon
  • Start date Start date
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top