View Single Post
  #1  
Old June 23rd 06, 05:26 PM posted to microsoft.public.outlook.program_vba
WhytheQ
external usenet poster
 
Posts: 21
Default Array of outlook items....HELP!!

I'm using the following code, from Excel, with no reference to Outlook:


Dim objOutlook As Object
Dim objMailItem As Object

Dim myCreatedEmails() As Object

Sub CreateAndDisplayEmails()

Set objOutlook = CreateObject("Outlook.Application")

Erase myCreatedEmails

For i = 1 To 3

Set objMailItem = objOutlook.CreateItem(0)

With objMailItem
.To = "Tester" & i
.Subject = "Tester" & i
End With

ReDim myCreatedEmails(k)
'##### falls down on next line #####
myCreatedEmails(k) = objMailItem
k = k + 1

Next i

For k = 1 To UBound(myCreatedEmails)
myCreatedEmails(k).Display
Next k

End Sub


....I've marked where it already falls down and I assume even if this
line is fixed then it'll fall down later on on the line
"myCreatedEmails(k).Display"

The above must be pretty bl##dy close!...can anyone help?

Help appreciated
Jason

Ads