Question: I have a VB6 program which I've been maintaining for ten years. There is a subroutine in the program called "Prepare Copy", which looks like this (Edited to add changes):

```
Public Sub PrepareCopy()

On Local Error GoTo PrepareCopyError

MsgBox "in modeldescription preparecopy"

Set CopiedShapes = New Collection

MsgBox "leaving preparecopy"
Exit Sub
PrepareCopyError:
    MsgBox Err.Description, , Err.Number
    Resume Next
End Sub

```

Where `CopiedShapes` is dimmed out as a VB6 Collection.

That code is now kicking out a Runtime Error 5 -- Invalid Procedure Call or Argument. It appears from the interstitial debugging code that the error arises *between* the `MsgBox "in modeldescription preparecopy"` and the `MsgBox "leaving preparecopy"` lines, and that the `On Error` code path never executes. 

Once the Error 5 dialog box is cleared, *then* the `MsgBox "leaving preparecopy"` dialog appears, after which the program closes out. 

It's behaving this way on my development machine and two client computers.

It is only happening in runtime code, and does not appear to make a difference whether I compile it or use P-Code 

What I'm asking for here is speculation as to what causes this sort of thing to happen.

Answer: 
Your recent comment says that the variable is `Public CopiedShapes as New Collection`.

1. Could you try removing the `new` in the declaration?
2. Are there any instances in the Collection with a `Sub Class_Terminate()` which are being called when the old Collection is garbage collected along with its contents?
Does the error occur only on machine/s different than where the code was compiled? It may be that some DLLs are missing in the runtime environment (like MSVBRT.dll or the like).  

Easiest way to figure it out: run on the build machine. 

If it doesn't happen there, you can create a deployable version (an installer) through VB6) that will include all that's needed. OR, use [SysInternals' Procmon](http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) to monitor the process as it runs and see which resource (file, DLL, reg key) it's attempting to access at the time of the error.