PDA

View Full Version : Outlook Application object visibility issue



malik641
06-04-2006, 11:46 AM
Hey Guys :hi:

Can someone explain to me why I get an error when trying to show an instance of outlook from excel? I get an "Object doesn't support this property or method" error in this code (bolded where the error is):

Sub test1()
Dim objOL As New Outlook.Application
objOL.Visible = True
Set objOL = Nothing
End Sub
I can get it to work like this:

Sub test1()
Dim objOL As Variant
objOL = Shell("Outlook.exe", vbMaximizedFocus)
End Sub
Why won't it work the first way? I have the reference set in the VBE...:dunno

malik641
06-04-2006, 11:48 AM
Oh yeah, and to further note...it won't work using late binding either:

Sub test1()
Dim objOL As Object
Set objOL = CreateObject("Outlook.Application")
objOL.Visible = True
Set objOL = Nothing
End Sub

Killian
06-05-2006, 02:31 AM
Hi Joseph,

The error object doesn't lie (at least not in this case). Strange tho it may seem, the Outlook application object doesn't have a Visible property.
("Strange" doesn't adequately describe it, does it?)

There is always the "Display" property, which you're probably familiar with as applied to mail items etc. but also applies to folders, so displaying the Inbox for example, will show the main application windowDim objOL As New Outlook.Application
Dim ns As Namespace
Dim fldr As MAPIFolder

Set ns = objOL.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(olFolderInbox)
fldr.Display

malik641
06-05-2006, 06:35 PM
Thanks Killian I see how I can get Outlook to show itself now.

You know, you would think that maybe outlook didn't have a Visible property for a specific reason...but I can't think of why :dunno

Anybody have any suggestions?