Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to detect version.......

  Asked By: Qadriyah    Date: Jan 23    Category: MS Office    Views: 615
  

In my vba code, i am trying to send out an email. It works fine with
outlook 2000, but when i test with Outlook 2003, it just fails. I dont
know whats going on. I am a novice to VBA, and need to be ready for my
presentation. Can some one guide me through this. I will really
appreciate it.

What i am doing is sending an email, with an attachment, using the
outlook object. i have all the references added to my code. Will
really appreciate the help.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Damon Perez     Answered On: Jan 23

There are significant differences between Outlook version  2000 and 2003.
If I were doing the coding, I would be sure and perform late binding to
let Excel & Outlook figure out how to allocate resources as appropriate.
Below is some code  I use to start an email  message from an Excel
spreadsheet. In it, I am only concerned with getting the addresses in
the bcc field, but you can see how I did it, and perhaps it will help
you.

#If EarlyBinding = 1 Then
Public objOLapp As Outlook.Application
Public objOLitem As Outlook.MailItem
#Else
Public objOLapp As Object
Public objOLitem As Object
#End If

Sub Test(strEmail As String)
On Error GoTo EH
Dim objOLapp As Object
Dim objOLitem As Object
Set objOLapp = CreateObject("Outlook.Application")
Set objOLitem = objOLapp.CreateItem(0)
With objOLitem
.Subject = ""
.CC = ""
.To = ""
.Body = ""
.bcc = strEmail
' .Attachments.Add '(path to the attachment,either hard coded or
variable)
.Display
End With
Set objOLapp = Nothing
Set objOLitem = Nothing
'Handle Errors Gracefully
Exit_EH:
Exit Sub

EH:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_EH

End Sub

 
Answer #2    Answered By: Betty Fischer     Answered On: Jan 23

So you mean early binding should take care of the issue.

 
Answer #3    Answered By: Mabel Davis     Answered On: Jan 23

I would design with early binding on, and then release the code  with late
binding. That way while you are designing and testing the code with your
version of Excel and Outlook, you get as much help from intellisense as you
possibly can, then change the code so that it uses late binding when you release
it to others with different versions of Outlook.

 
Didn't find what you were looking for? Find more on How to detect version....... Or get search suggestion and latest updates.




Tagged: