Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2013-11-11
Medium Priority
Last Modified: 2013-11-11

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"
End With


End Sub

I get the following error message in relation to olMailItem

Compile Error:

Can't find project or library

Could someone please assist?

Question by:f19l
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
LVL 76

Expert Comment

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

Author Comment

ID: 39638477
I have a reference already set to Microsoft Outlook 14.0 Object Library.

Accepted Solution

Michael earned 2000 total points
ID: 39638479
Hi there,

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

Open in new window

Set olMail = olApp.CreateItem(0)

Open in new window

This works for me in Excel 2010.


Author Comment

ID: 39638490
It works for me as well. Thanks.

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

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.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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