Needs Help With VBA Reference for Outlook

Greetings experts,

I am currently trying to automate tasks between Excel and Outlook, however, there seems to be a recurring issue.

I keep getting the "user-defined-type-not-defined" error despite already having ensured that the Microsoft reference under the Tools tab has been checked.

The line that the code appears to have this error is something like this
Dim App As New Outlook.Application

Open in new window


Any help is much appreciated! :)
LVL 4
An Average Forum Participant Just For FunHardware Tester and DebuggerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robberbaron (robr)Commented:
are you sure you have the correct version of the outlook library installed on the PC ?  And selected ?

I just tried your code and got the error when the outlook library was NOT selected.

worst case, you could use late binding
    Dim app As Object
    'Set app = New Outlook.Application
    On Error Resume Next
    Set app = GetObject(, "Outlook.Application")    '.CreateObject("Outlook.Application")
    Debug.Print Err.Number
    If Err.Number <> 0 Then
        Set app = CreateObject("Outlook.Application")
    End If
    On Error GoTo 0
    Debug.Print app.Version

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
An Average Forum Participant Just For FunHardware Tester and DebuggerAuthor Commented:
Thank you for your help! It works when I have updated the correct version of outlook and used your code
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.