M
mamuscia
I am having the worse time trying to manipulate the OLEObjects
collection. I am able to add objects to my Excel 2002 workbook, but I
have difficulty when trying to reference the objects I added by NAME.
Here is the code I use to add the imbedded file objects. How would I
then reference these objects by the NAME that I gave them instead of
the INDEX number. Does the INDEX number change as objects are deleted
from a Worksheet? Thanks.
filesel = Application.GetOpenFilename _
(FileFilter:="All files (*.*), *.*", _
Title:="Select Files to Attach", MultiSelect:=True)
If Not IsArray(filesel) Then Exit Sub
ws.Activate
OLEnum = ActiveSheet.OLEObjects.Count
For i = 1 To UBound(filesel)
thisFullName = filesel(i)
thisFile = Dir(thisFullName)
o = o + 1
ActiveSheet.OLEObjects.Add(Filename:=thisFullName, _
Link:=False, DisplayAsIcon:=True, _
IconFileName:="packager.exe", _
IconIndex:=0, IconLabel:=thisFile).Name = thisFile
OLEnum = OLEnum + 1
ActiveSheet.OLEObjects(OLEnum).Name = thisFile
With ActiveSheet.OLEObjects(OLEnum)
.top = rg.Cells(c).top
.Left = rg.Cells(c).Left
.Width = rg.Cells(c).Width
.Height = rg.Cells(c).Height
End With
c = c + 1
With Me.boxAttachments
.AddItem OLEnum
.List(boxAttachments.ListCount - 1, 1) = thisFile
End With
Next i
collection. I am able to add objects to my Excel 2002 workbook, but I
have difficulty when trying to reference the objects I added by NAME.
Here is the code I use to add the imbedded file objects. How would I
then reference these objects by the NAME that I gave them instead of
the INDEX number. Does the INDEX number change as objects are deleted
from a Worksheet? Thanks.
filesel = Application.GetOpenFilename _
(FileFilter:="All files (*.*), *.*", _
Title:="Select Files to Attach", MultiSelect:=True)
If Not IsArray(filesel) Then Exit Sub
ws.Activate
OLEnum = ActiveSheet.OLEObjects.Count
For i = 1 To UBound(filesel)
thisFullName = filesel(i)
thisFile = Dir(thisFullName)
o = o + 1
ActiveSheet.OLEObjects.Add(Filename:=thisFullName, _
Link:=False, DisplayAsIcon:=True, _
IconFileName:="packager.exe", _
IconIndex:=0, IconLabel:=thisFile).Name = thisFile
OLEnum = OLEnum + 1
ActiveSheet.OLEObjects(OLEnum).Name = thisFile
With ActiveSheet.OLEObjects(OLEnum)
.top = rg.Cells(c).top
.Left = rg.Cells(c).Left
.Width = rg.Cells(c).Width
.Height = rg.Cells(c).Height
End With
c = c + 1
With Me.boxAttachments
.AddItem OLEnum
.List(boxAttachments.ListCount - 1, 1) = thisFile
End With
Next i