View Single Post
  #6  
Old March 23rd 07, 05:56 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Open Outlook's inbox with VBA




OK, you must tell Explorer.Add a folder to display:

Dim ns as Outlook.Namespace
Dim Folder as Outlook.Mapifolder

Set ns=Olook.GetNamespace("MAPI")
Set Folder=ns.getDefaultFolder(olFolderInbox)

Olook.Explorers.Add Folder

Please test it, it might be necessary later to also delete the folder by
your code. You'll see that when Outlook doesn't close properly.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - The most effective way to assign Outlook categories:
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)
Am Thu, 22 Mar 2007 13:07:56 -0400 schrieb CES:

Michael Bauer [MVP - Outlook] wrote:

From any Office application, go to Tools/References and select Microsoft
Outlook... from the list.

If it's really necessary to have Outlook visible then modify your code a
little bit:

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



Michael,

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
Ads