How do you open MS Outlooks inbox??

C

CES

All,
I'm trying to open Outlook 2007 (Vista) but unfortunately I can't seem to get it to work. I have found different variations of the following:

Dim Olook As Outlook.Application
Set Olook = CreateObject("Outlook.Application")

Olook.Application.Visible = True


but when I attempt to run the code I get a compile error: "user defined type not defined."


Basically what I want to do is to open Outlook and go to the inbox. I was also hoping someone might know of a good resource to find simple Outlook code, that works?

If anyone can help me with this I would be grateful, Thanks in advance. - CES
 
P

Peter Yang [MSFT]

Hello,

From the error message, it seems that you didn't reference the proper
objects in VBA:

1. In the Visual Basic Editor, on the Tools menu, click References .
2. Click to select the Microsoft Outlook 12.0 Object Library check box,
and then click OK .

More realted informaiton:

324921 Other programs do not work after you exit Outlook
http://support.microsoft.com/default.aspx?scid=kb;EN-US;324921

Hope this helps.

Thanks & Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

CES

Peter said:
Hello,

From the error message, it seems that you didn't reference the proper
objects in VBA:

1. In the Visual Basic Editor, on the Tools menu, click References .
2. Click to select the Microsoft Outlook 12.0 Object Library check box,
and then click OK .

More realted informaiton:

324921 Other programs do not work after you exit Outlook
http://support.microsoft.com/default.aspx?scid=kb;EN-US;324921

Hope this helps.

Thanks & Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Peter,

I've added a reference to the Microsoft Outlook 12.0 Object Library as you suggested however I am still getting errors.


Public Sub test_Click()

Dim oL As Outlook.Application
Set oL = CreateObject("Outlook.Application")

'Either of these will throw an error
'oL.Explorers.Add ' Compile Error = "Argument not Optional"
'oL.Application.Visible = True ' Run-time error 438 = Object dosent support this property or method

End Sub

If by any chance you have a clue what else might be going wrong I would appreciate your help. - CES
 
P

Peter Yang [MSFT]

Hello,


You may want to test the code below to see if it helps:

Public Function test_outlook()

Dim olApp As Outlook.Application
Dim olNs As NameSpace

On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")

If Err.Number = 429 Then
Set olApp = CreateObject("Outlook.Application")
End If

On Error GoTo 0

Set olNs = olApp.GetNamespace("MAPI")

If olApp.ActiveExplorer Is Nothing Then
olApp.Explorers.Add _
(olNs.GetDefaultFolder(olFolderCalendar)).Activate
Else
Set olApp.ActiveExplorer.CurrentFolder = _
olNs.GetDefaultFolder(olFolderCalendar)
olApp.ActiveExplorer.Display
End If

Set olNs = Nothing
Set olApp = Nothing

End Function

Please see following link for more details:

http://www.dicks-clicks.com/excel/olBinding.htm

Hope this is helpful.

Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top