Selecting correct MS Outlook Object Library

P

Pete

I have used some code to send an email message via VBA using Microsoft
Outlook

As I have many users of the program (more than 50) each having different
versions of MS Office, the Microsoft Outlook Object Library that each
requires, differs (I guess liabry 9.0 to liabrary 11.0, but there may be
other libraries needed)

In the past (other projects with single users) the only way I could fix this
is was to ask the user to open up VBA go to Tools - References, delete the
"missing liabrary" and select the liabrary that is applicable to their
version of MS Office. If they updated the MS Office version then the
process had to be repeated - not ideal, but workable.

This project is of a bigger scale as different users will all access the
same file on a network so that manual method is now impossible.

Is there a way, in VBA, to set the correct liabrary upon opening the file?

I am on Excel 2003 using library Outlook 11.0
The subroutine that I use is listed below:

It picks up the email address (EmailAddress) and the message (MyMessage) off
the file in the process before branching to this sub-routine

Sub EmailUnansweredQuestioned(EmailAddress, MyMessage)
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Dim appOL
Dim oCtl As Office.CommandBarControl
Dim oPop As Office.CommandBarPopup
Dim oCB As Office.CommandBar
Dim oNS As Outlook.Namespace
Dim oItem As Object
Dim CC As String
Dim Response As String
Response = ""
MyMessage = "We have noted that certain questions from the Internal Control
Matrix (listed below) have still to be answered:" & vbCr & MyMessage & vbCr
& vbCr & "Please could you attend to this matter at your earliest
convenience." & vbCr & vbCr & "Thank you," & vbCr & "The ICM Team"
Response = MsgBox("Send the following message to " & EmailAddress & "?" &
vbCr & vbCr & MyMessage, vbYesNo)
If Response = vbYes Then
Set appOL = CreateObject("Outlook.Application")
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
With objMail
.To = EmailAddress
.Subject = "Internal Control Matrix"
.Body = MyMessage
.Send
End With
Set appOL = CreateObject("Outlook.Application")
Set oNS = appOL.GetNamespace("MAPI")
Set oCtl = appOL.ActiveExplorer.CommandBars.FindControl(ID:=5488)
'Reset objects
Set objMail = Nothing
Set objOL = Nothing
Set appOL = Nothing
Set oCtl = Nothing
End If
End Sub
 
B

Bob Phillips

The easiest way is to get a machine with the lowest version that any of your
users will use, and develop in that version. It will work on all versions
and save any grief of using functionality that they don't have.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top