This is my first try with collections and it is not going well. What I want to do is add the path of a file to the collect and have the filename as the index or unique id. The reason for this is to have the path so that the user can select files from Multiple directories. Nothing is working so below I have given the code for the class, the collection (both of which were created with the class builder wizard, I know bad programming) and the add button code, although I have not included the entire code for this section.

'***code for clsFileNamePath

Option Explicit

Private mvarcolFileNamePath As colFileNamePath


Public Property Get colFileNamePath() As colFileNamePath
If mvarcolFileNamePath Is Nothing Then
Set mvarcolFileNamePath = New colFileNamePath
End If


Set colFileNamePath = mvarcolFileNamePath
End Property


Public Property Set colFileNamePath(vData As colFileNamePath)
Set mvarcolFileNamePath = vData
End Property
Private Sub Class_Terminate()
Set mvarcolFileNamePath = Nothing
End Sub

'**code for collection colFileNamePath
Option Explicit

'local variable to hold collection
Private mCol As Collection

Public Function Add(colFileNamePath As colFileNamePath, Optional sKey As String) As clsFileNamePath
'create a new object
Dim objNewMember As clsFileNamePath
Set objNewMember = New clsFileNamePath


'set the properties passed into the method
Set objNewMember.colFileNamePath = colFileNamePath
If Len(sKey) = 0 Then
mCol.Add objNewMember
Else
mCol.Add objNewMember, sKey
End If


'return the object created
Set Add = objNewMember
Set objNewMember = Nothing


End Function

Public Property Get Item(vntIndexKey As String) As clsFileNamePath '
'used when referencing an element in the collection
'vntIndexKey contains either the Index or Key to the collection,
'this is why it is declared as a Variant
'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5)
Set Item = mCol(vntIndexKey)
End Property

Public Property Get Count() As Long
'used when retrieving the number of elements in the
'collection. Syntax: Debug.Print x.Count
Count = mCol.Count
End Property

Public Sub Remove(vntIndexKey As Variant)
'used when removing an element from the collection
'vntIndexKey contains either the Index or Key, which is why
'it is declared as a Variant
'Syntax: x.Remove(xyz)


mCol.Remove vntIndexKey
End Sub


Public Property Get NewEnum() As IUnknown
'this property allows you to enumerate
'this collection with the For...Each syntax
Set NewEnum = mCol.[_NewEnum]
End Property


Private Sub Class_Initialize()
'creates the collection when this class is created
Set mCol = New Collection
End Sub


Private Sub Class_Terminate()
'destroys collection when this class is terminated
Set mCol = Nothing
End Sub

'***code for adding to the collectionSet addPath = New colFileNamePath

n = 0
'pagenum = 0

On Error GoTo errorhandler

If lstSourceFiles.Text <> "" Then
'find the filename and the path so that it knows where to look for the file
'resultFile = FindFiles("D:\", inDirectory, lstSourceFiles.Text)
savedfile1 = lstSourceFiles.Text
savedfile = StripSpecialCharacters(savedfile1)
pdfFilename = Left$(savedfile, InStr(1, savedfile, " ") - 1)
'PageInfo = StripSpecialCharacters(savedfile)
FileNamePath = FindFile(pdfFilename, "D:\", sbStatusBar)
With addPath
.Add addPath, FileNamePath '= colFileNamePath
'.ItemaddPath.Item (pdfFilename)
End With
PgSize = GetFileInfo(pdfFilename)