473,466 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

reference library missing Microsoft Outlook 9.0 Object Library

4 New Member
Hi,

I am trying to run a simple macro in excel vba to create a new email and attach two spreadsheets. But it won't work. It stops at the first line everytime. Dim objOutlook As Outlook.Application

Do I need to install Microsoft Outlook 9.0 Object Library? When I go to Tools-->references I checked off MS outlook 9.0 Object Library. Then it tell me it is missing MS outlook 9.0 Object Library.

Appreciated if someone can give me some insight. I am new at write macros.

Thanks in advance.
Expand|Select|Wrap|Line Numbers
  1. Sub SendMsgwithAttachment()
  2.  
  3. Dim objOutlook As Outlook.Application
  4. Dim objOutlookMsg As Outlook.MailItem
  5. Dim objOutlookRecip As Outlook.Recipent
  6. Dim objOutlookAttach As Outlook.Attachment
  7.  
  8.  
  9. Dim RecipList As String
  10. Dim AttachmentPath As String
  11. Dim SubjectName As String
  12.  
  13. Sheets("Sheet1").Select
  14. RecipList = Range("B1").Value
  15. AttachmentPath = Range("B2").Value
  16. SubjectName = Range("B4").Value
  17. Filename = Range("B6:B7").Value
  18.  
  19.  
  20.  
  21. On Error Resume Next
  22.  
  23. Set objOutlook = CreatObject("Outlook.Application")
  24.  
  25. Set objOutlookMsg = objOutlook.createitem(olmailitem)
  26. With objOutlookMsg
  27.  
  28. Set objOutlookRecip = .Recipients.Add(RecipList)
  29. objOutlookRecip.Type = olTo
  30.  
  31.  
  32. .Subject = SubjectName
  33. .Body = " "
  34.  
  35. If Not IsMissing(AttachmentPath) Then
  36. Set objOutlookAttach = .Attachments.Add(AttachmentPath) & "\" & Array(Filename)
  37. End If
  38.  
  39. For Each objOutkRecip In .Recipients
  40.     objOutlookRecip.Resolve
  41.     If Not objOutlookRecip.Resolve Then
  42. Exit Sub
  43. End If
  44. Next
  45. .Display 'Display the message
  46. End With
  47.  
  48. Set objOutlookMsg = Nothing
  49. Set objOutlook = Nothing
  50.  
  51. End Sub
Sep 11 '07 #1
9 12557
Kevin Wilcox
68 New Member
Try searching for the Microsoft Outlook 9.0 Object Library (MSOUTL.OLB) in windows explorer, to find out if and where it's on your pc. If it's present, go back to Tools-->references and use 'browse' to add the file back in to the library. If it's missing, I'm fairly sure I have in the past simply copied a library file from another PC and referenced it like this.



Hi,

I am trying to run a simple macro in excel vba to create a new email and attach two spreadsheets. But it won't work. It stops at the first line everytime. Dim objOutlook As Outlook.Application

Do I need to install Microsoft Outlook 9.0 Object Library? When I go to Tools-->references I checked off MS outlook 9.0 Object Library. Then it tell me it is missing MS outlook 9.0 Object Library.

Appreciated if someone can give me some insight. I am new at write macros.

Thanks in advance.
Expand|Select|Wrap|Line Numbers
  1. Sub SendMsgwithAttachment()
  2.  
  3. Dim objOutlook As Outlook.Application
  4. Dim objOutlookMsg As Outlook.MailItem
  5. Dim objOutlookRecip As Outlook.Recipent
  6. Dim objOutlookAttach As Outlook.Attachment
  7.  
  8.  
  9. Dim RecipList As String
  10. Dim AttachmentPath As String
  11. Dim SubjectName As String
  12.  
  13. Sheets("Sheet1").Select
  14. RecipList = Range("B1").Value
  15. AttachmentPath = Range("B2").Value
  16. SubjectName = Range("B4").Value
  17. Filename = Range("B6:B7").Value
  18.  
  19.  
  20.  
  21. On Error Resume Next
  22.  
  23. Set objOutlook = CreatObject("Outlook.Application")
  24.  
  25. Set objOutlookMsg = objOutlook.createitem(olmailitem)
  26. With objOutlookMsg
  27.  
  28. Set objOutlookRecip = .Recipients.Add(RecipList)
  29. objOutlookRecip.Type = olTo
  30.  
  31.  
  32. .Subject = SubjectName
  33. .Body = " "
  34.  
  35. If Not IsMissing(AttachmentPath) Then
  36. Set objOutlookAttach = .Attachments.Add(AttachmentPath) & "\" & Array(Filename)
  37. End If
  38.  
  39. For Each objOutkRecip In .Recipients
  40.     objOutlookRecip.Resolve
  41.     If Not objOutlookRecip.Resolve Then
  42. Exit Sub
  43. End If
  44. Next
  45. .Display 'Display the message
  46. End With
  47.  
  48. Set objOutlookMsg = Nothing
  49. Set objOutlook = Nothing
  50.  
  51. End Sub
Sep 12 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Have a look down the references list and see if there is another version of the library besides 9.0

What version of Office are you using?
Sep 12 '07 #3
CoCoCha
4 New Member
Have a look down the references list and see if there is another version of the library besides 9.0

What version of Office are you using?
MS 2000
I only have 9.0 right now I found it at the list and check it again. I get a message box when I run the macro.

A program is trying to access email address you have stored in Outlook. Do you want to allow this?

Allow access for 1 min or 10 mins options: Yes, No, Help. I press Yes.

another box appears.

Miscrosoft Excel is waiting for another application to complete an OLE action.

Ok button

what does OLE mean here?

I just keep on getting this message. I can't get a Outlook msg box to appear.
Sep 13 '07 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
Create breakpoint stops in your code. See how far you get before the OLE message appears.
Sep 13 '07 #5
CoCoCha
4 New Member
Create breakpoint stops in your code. See how far you get before the OLE message appears.

it starts to display OLE message when I get to.

Set objOutlookRecip = .Recipients.Add(RecipList) before

I have the email address saved in a cell in the spreadsheet.

cell A2: joe.bob@yahoo.com ; anne.mary@yahoo.com

then nothing after I just let it make connection with Outlook
Sep 18 '07 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Have a look at this declaration

Dim objOutlookRecip As Outlook.Recipent

Now change it to

Dim objOutlookRecip As Outlook.Recipients

Does that make a difference
Sep 18 '07 #7
FishVal
2,653 Recognized Expert Specialist
Hi, CoCoCha.

I think you have faulty code line.
Comment
Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2.  
and see there does it fail. I suppose you don't want to ignore all errors at this time. ;)

I've run this simplified code in Excel module with no problema.
Expand|Select|Wrap|Line Numbers
  1. Public Sub qqq()
  2.  
  3.     Dim appOutlook As Outlook.Application
  4.     Dim objMail As Outlook.MailItem
  5.  
  6.     Set appOutlook = CreateObject("Outlook.Application")
  7.     Set objMail = appOutlook.CreateItem(olMailItem)
  8.  
  9.     With objMail
  10.         With .Recipients.Add("qqq")
  11.             .Type = olTo
  12.         End With
  13.         .Subject = "qqq"
  14.         .Body = "qqq"
  15.         .Display
  16.     End With
  17.  
  18.     Set objMail = Nothing
  19.     Set appOutlook = Nothing
  20.  
  21. End Sub
  22.  
  23.  
Sep 18 '07 #8
CoCoCha
4 New Member
Have a look at this declaration

Dim objOutlookRecip As Outlook.Recipent

Now change it to

Dim objOutlookRecip As Outlook.Recipients

Does that make a difference
Hi M. McCarthy
Thanks for your help.

I changed the line but didn't change anything. It still stopped right at that line for debug. OLE message prompt up I grant access for one minute and nothing happens.
Sep 20 '07 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi M. McCarthy
Thanks for your help.

I changed the line but didn't change anything. It still stopped right at that line for debug. OLE message prompt up I grant access for one minute and nothing happens.
The problem may be that you are adding more than one address in the recipient list. Try changing your code to add one address at a time.
Sep 21 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Job Lot | last post by:
I am retrieving message from the Inbox as follows: (MS Article ID 310258: How to use the Microsoft Outlook Object Library to retrieve a message from the Inbox by using Visual C# .NET) Try Dim...
0
by: Brad | last post by:
Hi all, I've been using the well document Click Yes program for auto sending emails for some time now and it has done it's job perfectly. In fact I have been so impressed with this that I've...
4
by: rockio | last post by:
I have two computers with MS Access 2000 installed. However one computer has Microsoft Outlook 2002 installed while the other does not. The computer without Microsoft Outlook 2002 does not seem to...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
2
by: John Davis | last post by:
In VB.NET, sounds like we no longer can use Microsoft Outlook Object Library (MSOUTL.OLB)?? But Microsoft Excel and Word object library still exist. In VB6, we can just add outlook library...
3
by: AP | last post by:
I have an app that has one small component that uses a reference to MS Outlook 9.0 to create an email. Now we have users on 9.0 and 11.0, sometimes it causes the reference to switch and this causes...
1
by: larpup | last post by:
I have a A2000 mdb and it is missing Microsoft Outlook 9.0 library.... I see that it is not listed. How can I get this into my references? Lar
3
by: NEWSGROUPS | last post by:
I am in the midst of trying to convert about 25 Access 2000 to Access 2003. The new environment consists of Office/Access 2003 and Outlook 2003. When converting the back ends I have no problems....
1
by: Sylfelin | last post by:
Hello, If I use Microsoft Outlook 12.0 Object Library (Outlook 2007) COM Object in my application, the custommer must have the outlook 2007 on his computer ? But if i use Microsoft Outlook...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.