Outlook consolidate files

Viewed 34

I have the following macro to extract and combine excel files from outlook. The macro does not work on the start with variables declaration. I get an error:

"Compile error
User-defined type not defined"
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
1 Answers

It seems you need to add a COM reference in your VBA environment. Use the Reference command on the Visual Basic for Applications (VBA) Tools menu to set a reference to Microsoft Outlook xx.x Object Library, where xx.x represents the version of Outlook that you are working with. See Automating Outlook from a Visual Basic Application for more information.

Also you may need to prepend the type declarations with a host name (namespace):

Dim OutlookNamespace As Outlook.Namespace
Dim Folder As Outlook.MAPIFolder
Related