Results 1 to 4 of 4
  1. #1
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts


    I am running an Access App to Invoke and send an email.
    I do NOT want to use specific office libraries because there are various versions of Office in Use,
    and so referncing Outlook 11 cause issues when used by someone with just office 9.

    Instead I am using GetObject or CreateObject


    Set objOut = GetObject(, "Outlook.Application")
    If Err.Number = 429 Then
    Set objOut = CreateObject("Outlook.Application")
    fOpen = False
    fCreated = True
    ElseIf objOut Is Nothing Then
    Set objOut = CreateObject("Outlook.Application")
    fOpen = False
    fCreated = True
    Else
    fOpen = True
    fCreated = False
    End If

    'This Invokes an existing Outlook Instance if Open and Creates a New Instance if Not.

    I have tested it in both cases and it works fine and will create and send an email.

    However, IF Outlook is opened I want to make it visible after the email has been sent.
    (User request NOT my idea).

    I added this code into the process.

    'Show Outlook
    If fCreated = True Then
    objOut.Application.Visible = True
    End If

    I also tried just objOut.Visible=Trie

    The code is executed and does NOT generate any errors, but
    Outlook does not become visible.

    Indeed it does not even appear in the Task manager Process Stack.

    Is there any way to actually get the Outlook Application Visible?

    I am sure it is simple, BUT I have missed it somewhere.
    Andrew

  2. #2
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I also tried this

    objNameSpace = objOut.GetNamespace("mapi")
    objDefaultFolder = objNameSpace.Getdefaultfolder(6) '6 is olFolderInBox
    objDefaultFolder.Display

    BUT No joy.

    Strangely, IF I create a Mail Message
    and then invoke the display method it appears,
    BUT not Outlook, only the message box.

    e.g.

    objMailItem.Display
    Andrew

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The Outlook.Application object does not have a Visible property. The main Outlook window is a so-called Explorer. To show it, use code like this:

    Dim objNSP As Object
    Dim objExp As Object
    Dim objFld As Object

    Set objNSP = objOL.GetNamespace("MAPI")
    Set objFld = objNSP.GetDefaultFolder(6) ' 6 = olFolderInbox
    Set objExp = objOL.Explorers.Add(objFld, 0) ' 0 = olFolderDisplayNormal
    objExp.Activate


    This will create an Explorer that shows the user's Inbox and activate it. See the Object Browser in the Outlook VBE for the values for other folders.

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    [quote name='HansV' post='796904' date='08-Oct-2009 11:30']The Outlook.Application object does not have a Visible property. The main Outlook window is a so-called Explorer. To show it, use code like this:

    Dim objNSP As Object
    Dim objExp As Object
    Dim objFld As Object

    Set objNSP = objOL.GetNamespace("MAPI")
    Set objFld = objNSP.GetDefaultFolder(6) ' 6 = olFolderInbox
    Set objExp = objOL.Explorers.Add(objFld, 0) ' 0 = olFolderDisplayNormal
    objExp.Activate


    This will create an Explorer that shows the user's Inbox and activate it. See the Object Browser in the Outlook VBE for the values for other folders.[/quote]


    Originally by me 'I am sure it is simple, BUT I have missed it somewhere.'
    Excellent!
    Thanks Hans, totally sorted (works a treat).
    Andrew

Posting Permissions

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