Solved

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

Posted on 2014-12-09
5
182 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
ID: 40490400
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
ID: 40490483
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
ID: 40490510
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
ID: 40490693
Can we see the code, including the declarations?
0
 

Author Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

932 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