Consulting

Results 1 to 4 of 4

Thread: Outlook Application object visibility issue

  1. #1
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location

    Outlook Application object visibility issue

    Hey Guys

    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):

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

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




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  2. #2
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Oh yeah, and to further note...it won't work using late binding either:
    [VBA]
    Sub test1()
    Dim objOL As Object
    Set objOL = CreateObject("Outlook.Application")
    objOL.Visible = True
    Set objOL = Nothing
    End Sub[/VBA]




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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 window[VBA]Dim 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[/VBA]
    K :-)

  4. #4
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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

    Anybody have any suggestions?




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •