Outlook.Application generates compiler error

  • Thread starter Thread starter Christopher Glaeser
  • Start date Start date
C

Christopher Glaeser

Attempts to compile Access modules to improve performance results in a
compiler error on the following declaration.

Dim objOutlook As Outlook.Application

Any suggestions on how to compile this? Should objOutlook be declared as an
Object?

Best,
Christopher
 
Public Sub TestSub3()

'This is early binding. It requires a reference
'(Tools, References in the VBA editor) to the
'Microsoft Outlook x.x Object Library (where 'x.x'
'is the version of Outlook you are using. Your
'users will have to be using the same version of
'Outlook.
Dim objOutlook1 As Outlook.Application
Set objOutlook1 = New Outlook.Application
Debug.Print objOutlook1.ProductCode
Set objOutlook1 = Nothing

'This is late binding. Less developer friendly
'(no Intellisense lists) but does not require
'a reference and will work with earlier versions
'of Outlook - if you don't use new features
'that were not supported in the earlier version.
Dim objOutlook2 As Object
Set objOutlook2 = CreateObject("Outlook.Application")
Debug.Print objOutlook2.ProductCode
Set objOutlook2 = Nothing

End Sub
 
'This is early binding. It requires a reference
'(Tools, References in the VBA editor) to the
'Microsoft Outlook x.x Object Library (where 'x.x'
'is the version of Outlook you are using.

Thanks. I added the reference for Microsoft Outlook 11.0 Object Library,
but the error message "user-defined type is not defined" is still generated
by the compiler. Any other suggestins?

Best,
Christopher
 
Oops, found the problem. I added a reference for Micosoft.Office 11.0
Object Library, and should have added a reference for Microsoft.Outlook 11.0
Object Library.

Best,
Christopher
 
Back
Top