Posted to microsoft.public.excel.programming
|
|
Outlook - Different Versions
Dick
Fantastic!
Thank you
S
-----Original Message-----
S
My code now look like this. Worked fine on my machine
but
when testing it with a friend they told me it was a
mixture of early and late binding! Would you mind
helping
again? Also in my OL version code I use
arrVer = Split(strVersion, ".")
Apparently this doesn't work for XL 97, can I use
something else?
Tell them to upgrade. Just kidding, use this function
instead
http://www.dicks-blog.com/excel/2004/05/split97.html
See inline below
Sub SimpleSender()
'CheckOLVersion
'MsgBox CheckOLVersion
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim objOutlookMsg As Outlook.MailItem
No variables should be dimmed as Outlook.Anything. All
Outlook variables
need to be dimmed as Object
'Open Outlook
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
olMailItem is a constant that resides in the Outlook
Library. When your
code compiles, it doesn't know about that library yet,
so you have to use
the constant's intrinsic value.
objOutlook.CreateItem(0)
zero is the intrinsic value for that constant. To find
these values, use
the Immediate Window (with the reference still set)
?olMailItem
0
With objOutlookMsg
.Display
.Recipients.Add "sophie"
.subject = "Believe it or not ........"
.Body = "This works"
.Send
End With
Set objOutlook = Nothing
End Sub
Everything else looks fine. Before you send it, uncheck
the Outlook
reference on your machine. Then you can compile and run
it and see if you
missed any early-binding stuff.
--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com
.
|