?
Solved

Problems running macros due to migration from Windows XP Excel 2007 to Windows 7 Enterprise Excel 2010

Posted on 2013-11-11
4
Medium Priority
?
422 Views
Last Modified: 2013-11-11
Hello,

I used to be able to run the following macro in Excel 2007 but can no longer in Excel 2010.

Sub Email_Rates_Update()
Dim olApp As Outlook.Application, olMail As Outlook.MailItem

Dim rngeSend As Range, strHTMLBody As String

Application.DisplayAlerts = False

Set olApp = CreateObject("Outlook.Application")

Set olMail = olApp.CreateItem(olMailItem)

With olMail
.SentOnBehalfOfName = "xxxxx"
.To = "xxxxx"
.Subject = "xxx"
.Send
End With

Sheets("CONTROL").Select

End Sub

I get the following error message in relation to olMailItem

Compile Error:

Can't find project or library

Could someone please assist?

Thanks.
0
Comment
Question by:f19l
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39638474
You will need to set a reference to the Microsoft Outlook Object Library (Tools/References in the VBA IDE)
0
 

Author Comment

by:f19l
ID: 39638477
I have a reference already set to Microsoft Outlook 14.0 Object Library.
0
 
LVL 6

Accepted Solution

by:
Michael earned 2000 total points
ID: 39638479
Hi there,

maybe it works if you change
 Set olMail = olApp.CreateItem(olMailItem)

Open in new window

to
Set olMail = olApp.CreateItem(0)

Open in new window

This works for me in Excel 2010.

Joop
0
 

Author Comment

by:f19l
ID: 39638490
It works for me as well. Thanks.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question