Link to home
Start Free TrialLog in
Avatar of upobDaPlaya
upobDaPlaya

asked on

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

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)
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Turn on Option Explicit :)

Note that applOL <> appOL.  Fix that misspelling.

Also, your dim statement should have "Outlook.Application", not "Outlook Application".
Avatar of upobDaPlaya
upobDaPlaya

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Removing and reselecting worked....bizarre..thanks imnorie for reaching out though