Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook.Application not defined 1

Status
Not open for further replies.

Lunatic

Technical User
May 8, 2006
405
US
I borrowed the following code from another thread:
Code:
Private Sub cmdEmailTrackingNumber1_Click()
On Error GoTo Err_cmdEmailTrackingNumber1_Click
Dim strEmail, strBody As String
[highlight]Dim objOutlook As Outlook.Application[/highlight]
Dim objEmail As Outlook.MailItem

However I get a 'User-defined type not defined' error for the highlighted part. As its Outlook I'm trying to use and our office is standardized with Office 2002, I don't understand why it wouldn't be pre-defined.

In the Access VBA interface I tired to go the reference option to see what is being referenced, but its grayed out.

So I have 2 questions:
1) Can I specifcy the Outlook reference in the code manually?
2) Any suggestions on how to un-gray-out the Reference option under 'Tools'?

Thank you!

***************************************
Have a problem with my spelling or grammar? Please refer all complaints to my English teacher:
Ralphy "Me fail English? That's unpossible." Wiggum
 
I have had this problem before, and fixed it by using late binding. This is accomplished throuhg changing declaration to simply

Code:
Dim objOutlook

You then declare its type in your create object statement.

I hope I am explaining this properly.

Hope it helps,

Alex

A wise man once said
"The only thing normal about database guys is their tables".
 
Did you try to go to the reference option in the middle of debugging? If so, try looking at the references before running the code. As you suspect, it is a missing reference, you need to refer to the Outlook Object Library, unless you wish to use 'late binding' (Dim objOL as Object), but if you do that, you will need to use values instead of names for constants.
 
Ah... I was in the middle of Debugging. I was trying to change things. I went back in an turned on everything that said Outlook and no longer am stuck... At that part... Now I just have to keep learning.

Thanks!

***************************************
Have a problem with my spelling or grammar? Please refer all complaints to my English teacher:
Ralphy "Me fail English? That's unpossible." Wiggum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top