Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Outlook - Different Versions

Hello Everyone!

I'm sending out a spreadsheet with some code which people
will run to email me back. Sometimes it crashes because
everyone out there has a different version of Outlook.

I've had a good look through the postings on here and
think it's because the reference files are different.
I've got a found function that will tell me what version
everyone out there is using. But I don't know what to do
then?

I think it's one of the posts but it's just too
complicated for me, I'm new to VB.

My code is below.

If anyone could help I'd be very grateful

Sxx

Sub SimpleSender()

CheckOLVersion

MsgBox CheckOLVersion

Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem


'Open Outlook
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg

.Display
.Recipients.Add "Sophie"
.subject = "Tester"
.Body = "Here I am"
'.Send

End With

Set objOutlook = Nothing


End Sub
Function CheckOLVersion() ' As String
Dim objOL ' As Outlook.Application
Dim strVersion ' As String
Dim arrVer
On Error Resume Next

Set objOL = CreateObject("Outlook.Application")
strVersion = objOL.Version
If Err Then
' Outlook 97
CheckOLVersion = "97"
Exit Function
End If

arrVer = Split(strVersion, ".")
Select Case CInt(arrVer(0))
Case 8 ' Outlook 98
CheckOLVersion = "98"
Case 9 ' Outlook 2000
CheckOLVersion = "2000"
Case 10 ' Outlook 2002
CheckOLVersion = "2002"
Case 11 ' Outlook 2003
CheckOLVersion = "2003"
End Select
Set objOL = Nothing
End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Outlook - Different Versions

Sophie

You need to use "late binding" and let VBA determine the correct reference.
See here

http://www.dicks-clicks.com/excel/olBinding.htm


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Sophie" wrote in message
...
Hello Everyone!

I'm sending out a spreadsheet with some code which people
will run to email me back. Sometimes it crashes because
everyone out there has a different version of Outlook.

I've had a good look through the postings on here and
think it's because the reference files are different.
I've got a found function that will tell me what version
everyone out there is using. But I don't know what to do
then?

I think it's one of the posts but it's just too
complicated for me, I'm new to VB.

My code is below.

If anyone could help I'd be very grateful

Sxx

Sub SimpleSender()

CheckOLVersion

MsgBox CheckOLVersion

Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem


'Open Outlook
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg

.Display
.Recipients.Add "Sophie"
.subject = "Tester"
.Body = "Here I am"
'.Send

End With

Set objOutlook = Nothing


End Sub
Function CheckOLVersion() ' As String
Dim objOL ' As Outlook.Application
Dim strVersion ' As String
Dim arrVer
On Error Resume Next

Set objOL = CreateObject("Outlook.Application")
strVersion = objOL.Version
If Err Then
' Outlook 97
CheckOLVersion = "97"
Exit Function
End If

arrVer = Split(strVersion, ".")
Select Case CInt(arrVer(0))
Case 8 ' Outlook 98
CheckOLVersion = "98"
Case 9 ' Outlook 2000
CheckOLVersion = "2000"
Case 10 ' Outlook 2002
CheckOLVersion = "2002"
Case 11 ' Outlook 2003
CheckOLVersion = "2003"
End Select
Set objOL = Nothing
End Function




  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Outlook - Different Versions

Thanks Dick

Very clearly expressed!!

S



-----Original Message-----
Sophie

You need to use "late binding" and let VBA determine the

correct reference.
See here

http://www.dicks-clicks.com/excel/olBinding.htm


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Sophie" wrote in

message
...
Hello Everyone!

I'm sending out a spreadsheet with some code which

people
will run to email me back. Sometimes it crashes because
everyone out there has a different version of Outlook.

I've had a good look through the postings on here and
think it's because the reference files are different.
I've got a found function that will tell me what

version
everyone out there is using. But I don't know what to

do
then?

I think it's one of the posts but it's just too
complicated for me, I'm new to VB.

My code is below.

If anyone could help I'd be very grateful

Sxx

Sub SimpleSender()

CheckOLVersion

MsgBox CheckOLVersion

Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem


'Open Outlook
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg

.Display
.Recipients.Add "Sophie"
.subject = "Tester"
.Body = "Here I am"
'.Send

End With

Set objOutlook = Nothing


End Sub
Function CheckOLVersion() ' As String
Dim objOL ' As Outlook.Application
Dim strVersion ' As String
Dim arrVer
On Error Resume Next

Set objOL = CreateObject("Outlook.Application")
strVersion = objOL.Version
If Err Then
' Outlook 97
CheckOLVersion = "97"
Exit Function
End If

arrVer = Split(strVersion, ".")
Select Case CInt(arrVer(0))
Case 8 ' Outlook 98
CheckOLVersion = "98"
Case 9 ' Outlook 2000
CheckOLVersion = "2000"
Case 10 ' Outlook 2002
CheckOLVersion = "2002"
Case 11 ' Outlook 2003
CheckOLVersion = "2003"
End Select
Set objOL = Nothing
End Function




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Outlook - Different Versions

Hi Dick

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?

Thank you

S

Sub SimpleSender()

'CheckOLVersion

'MsgBox CheckOLVersion

Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")

Dim objOutlookMsg As Outlook.MailItem

'Open Outlook
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg

.Display
.Recipients.Add "sophie"
.subject = "Believe it or not ........"
.Body = "This works"
.Send

End With

Set objOutlook = Nothing


End Sub

-----Original Message-----
Thanks Dick

Very clearly expressed!!

S



-----Original Message-----
Sophie

You need to use "late binding" and let VBA determine

the
correct reference.
See here

http://www.dicks-clicks.com/excel/olBinding.htm


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Sophie" wrote in

message
.. .
Hello Everyone!

I'm sending out a spreadsheet with some code which

people
will run to email me back. Sometimes it crashes

because
everyone out there has a different version of Outlook.

I've had a good look through the postings on here and
think it's because the reference files are different.
I've got a found function that will tell me what

version
everyone out there is using. But I don't know what to

do
then?

I think it's one of the posts but it's just too
complicated for me, I'm new to VB.

My code is below.

If anyone could help I'd be very grateful

Sxx

Sub SimpleSender()

CheckOLVersion

MsgBox CheckOLVersion

Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem


'Open Outlook
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg

.Display
.Recipients.Add "Sophie"
.subject = "Tester"
.Body = "Here I am"
'.Send

End With

Set objOutlook = Nothing


End Sub
Function CheckOLVersion() ' As String
Dim objOL ' As Outlook.Application
Dim strVersion ' As String
Dim arrVer
On Error Resume Next

Set objOL = CreateObject("Outlook.Application")
strVersion = objOL.Version
If Err Then
' Outlook 97
CheckOLVersion = "97"
Exit Function
End If

arrVer = Split(strVersion, ".")
Select Case CInt(arrVer(0))
Case 8 ' Outlook 98
CheckOLVersion = "98"
Case 9 ' Outlook 2000
CheckOLVersion = "2000"
Case 10 ' Outlook 2002
CheckOLVersion = "2002"
Case 11 ' Outlook 2003
CheckOLVersion = "2003"
End Select
Set objOL = Nothing
End Function




.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Outlook - Different Versions

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




  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
custimized outlook today in outlook 2007 Hal Excel Discussion (Misc queries) 2 June 20th 07 12:59 AM
excel open in outlook if outlook is running kirk Excel Discussion (Misc queries) 0 May 24th 06 06:42 PM
Outlook 11 Outlook 10 Object Library Compatibility Issues Paul Mac[_4_] Excel Programming 11 May 19th 06 04:27 AM
Please include fonts from previous versions ('98) in new versions JJBQ Excel Discussion (Misc queries) 3 October 8th 05 07:19 PM
Display mail application either in Outlook, or Outlook express [email protected] Excel Programming 0 April 13th 04 09:50 PM


All times are GMT +1. The time now is 02:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"