Solved

Why a type mismatch on Excel VBA that creates an Outlook email

Posted on 2014-12-09
5
180 Views
Last Modified: 2014-12-14
I have some code within Excel that creates an email, but I am getting a Type mismatch error.  I checked and I appear to have all the correct references set.  It is failing at SetappMail = appOL.CreateItem(0)

Dim applOL as Outlook Application, appMail As Outlook.MailItem,,,,,,,,,other Dim Outlook statements, etc.

Set appOL = New Outlook.Application: Set appMail = appOL.CreateItem(0)
0
Comment
Question by:upobDaPlaya
  • 2
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Turn on Option Explicit :)

Note that applOL <> appOL.  Fix that misspelling.

Also, your dim statement should have "Outlook.Application", not "Outlook Application".
0
 

Author Comment

by:upobDaPlaya
Comment Utility
Sorry I should have included all the code, but on a different PC.

I used Option Explicit
appOL is not mispelled in the original code
The DIM statement does have "Outlook.Application"

Any other suggestions...Note this same code works for others..I am the only one getting the type mismatch error
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 450 total points
Comment Utility
Could be a problem with the reference.  Remove the reference, add it back, and compile.
0
 
LVL 33

Assisted Solution

by:Norie
Norie earned 50 total points
Comment Utility
Can we see the code, including the declarations?
0
 

Author Closing Comment

by:upobDaPlaya
Comment Utility
Removing and reselecting worked....bizarre..thanks imnorie for reaching out though
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now