Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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 how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

856 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