Needs Help With VBA Reference for Outlook

Noah
Noah used Ask the Experts™
on
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! :)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

NoahHardware Tester and Debugger

Author

Commented:
Thank you for your help! It works when I have updated the correct version of outlook and used your code

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial