Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Selecting correct MS Outlook Object Library

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:=5 488)
'Reset objects
Set objMail = Nothing
Set objOL = Nothing
Set appOL = Nothing
Set oCtl = Nothing
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Selecting correct MS Outlook Object Library

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)

"Pete" wrote in message
...
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:=5 488)
'Reset objects
Set objMail = Nothing
Set objOL = Nothing
Set appOL = Nothing
Set oCtl = Nothing
End If
End Sub




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
Help with Object Library Ayo Setting up and Configuration of Excel 1 November 6th 09 08:04 PM
Microsoft Outlook Library splodgey Excel Discussion (Misc queries) 2 August 9th 07 03:58 PM
Outlook 11.0 Library Bret Excel Programming 10 August 3rd 06 05:58 AM
Outlook 11 Outlook 10 Object Library Compatibility Issues Paul Mac[_4_] Excel Programming 11 May 19th 06 04:27 AM
Attaching an Outlook Library programatically Richard Buttrey Excel Programming 3 August 4th 05 10:47 AM


All times are GMT +1. The time now is 01:52 AM.

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

About Us

"It's about Microsoft Excel"