View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Open second Excel file with VBA

The "on error goto 0" line is the way you tell VBA that you don't want to ignore
any more errors. And that you don't want to handle them if they occur. You're
willing to accept whatever excel/vba does when it sees an error.

There are lots of errors that could arise in your code. You may not have enough
space on the disk to do the copy. You may not have access rights to do the
copy. Maybe the user didn't install Scripting (as a security measure???).

You'll have to decide if those are important--and how you'd want to handle them
if they are.



Gustaf wrote:

Dave Peterson wrote:

I'd use:

sheetName = ActiveWorkbook.ActiveSheet.Name
set ws = nothing
on error resume next
Set ws = xlTmp.Sheets(sheetName)
on error goto 0
If ws is nothing Then


Great, it works! But what's the meaning of "On Error GoTo 0" here? It appears the only error I need to look out for is that sheetName is out of range.

Gustaf


--

Dave Peterson