Solved

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

Posted on 2014-12-09
5
185 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

735 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