appOutlook.visible niet toegestaan

Status
Niet open voor verdere reacties.

JelleKoen

Gebruiker
Lid geworden
30 okt 2012
Berichten
58
Goedemiddag,
Word en Excel start ik met vba in een algemene module. Dat wil ik nu ook met Outlook, maar de applicatie wordt niet zichtbaar.
En de opdracht appOutlook.visible is, anders dan bij Word en Excel, niet toegestaan. Graag even hulp.
(Ik heb de On Error bij prcActivateOutlook even als tekst gemarkeerd)

Code:
Sub prcActivateWord()
    Public appWord           As New Word.Application
    On Error Resume Next
    Set appWord = GetObject(, "Word.application")
    If appWord = "" Then
        Set appWord = CreateObject("Word.application")
    End If
    appWord.Visible = True
End Sub
Sub prcActivateExcel()
    Public appExcel           As New Excel.Application
    On Error Resume Next
    Set appExcel = GetObject(, "Excel.application")
    If appExcel = "" Then
        Set appExcel = CreateObject("Excel.application")
    End If
    appExcel.Visible = True
End Sub
Sub prcActivateOutlook()
    Public appOutlook         As New Outlook.Application
    'On Error Resume Next
    Set appOutlook = GetObject(, "Outlook.application")
    If appOutlook = "" Then
        Set appOutlook = CreateObject("Outlook.application")
    End If
    appOutlook.Visible = True
End Sub
 
De .Visible methode is er niet voor Outlook.
Je moet Outlook laten weten welke folder je wilt openen.
Dus zoiets:
Code:
Sub OpenOutlookFolder()
    Dim xOutlookApp As Outlook.Application
    Dim xNameSpace As Outlook.Namespace
    Dim xFolder As Outlook.Folder
    
    Set xOutlookApp = New Outlook.Application
    Set xNameSpace = xOutlookApp.Session
    Set xFolder = xNameSpace.GetDefaultFolder(olFolderInbox)
    xFolder.Display
End Sub
 
Je mag je vraag nog op <Opgelost> zetten. Tenzij je nog meer vragen hebt natuurlijk :).
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan