Ga naar hoofdinhoud

Hoe automatisch alle mappen uitvouwen bij het starten van Outlook?

Wanneer u een map in het navigatiedeelvenster van Outlook uit- of samenvouwt en vervolgens het programma sluit, behoudt de map doorgaans de uitgevouwen of samengevouwen status bij het opnieuw openen van Outlook. Maar wat als u wilt dat alle mappen automatisch worden uitgevouwen telkens wanneer u Outlook start? Dit artikel biedt een VBA-oplossing om precies dat te bereiken.

Vouw automatisch alle mappen uit wanneer u Outlook start met VBA

Office-tabblad - Schakel bewerken en bladeren met tabbladen in Microsoft Office in, waardoor werken een fluitje van een cent wordt
Kutools voor Outlook - Geef Outlook een boost met meer dan 100 geavanceerde functies voor superieure efficiëntie
Geef uw Outlook 2021 - 2010 of Outlook 365 een boost met deze geavanceerde functies. Geniet van een uitgebreide gratis proefperiode van 60 dagen en verbeter uw e-mailervaring!

pijl blauw rechts bel Vouw automatisch alle mappen uit wanneer u Outlook start met VBA

In deze handleiding wordt gedemonstreerd hoe u een VBA-script kunt gebruiken om automatisch alle mappen in het navigatiedeelvenster uit te vouwen telkens wanneer u Outlook start. Volg deze stappen om het VBA-script te implementeren:

  1. Media Alt + F11 toetsen tegelijkertijd om het Microsoft Visual Basic voor toepassingen venster.
  2. Vouw de project 1 en Microsoft Outlook-objecten in de Project deelvenster, dubbelklik om het DezeOutlookSessie venster en plak vervolgens de onderstaande VBA-code erin.

    VBA: vouw automatisch alle mappen in Outlook uit

    Public WithEvents GEx As Explorer
    Public GFlag As Boolean
    Private Sub Application_Startup()
      'Update by ExtendOffice 2023/12/08
      Set GEx = Application.ActiveExplorer
      GFlag = False
    End Sub
    
    Private Sub GEx_SelectionChange()
      If GFlag = False Then
        ExpandAllFolders
      End If
      GFlag = True
    End Sub
    
    Public Sub ExpandAllFolders()
      Dim xNameSpace As Outlook.NameSpace
      Dim xFlds As Outlook.Folders
      Dim xCurrFld As Outlook.MAPIFolder
      Dim xFld As Outlook.MAPIFolder
      Dim xExpandDefaultStoreOnly As Boolean
      Dim xModule As NavigationModule
      On Error Resume Next
      xExpandDefaultStoreOnly = False
      Set xNameSpace = Application.Session
      Set xModule = Application.ActiveExplorer.NavigationPane.CurrentModule
      Set xCurrFld = Application.ActiveExplorer.CurrentFolder
      If xExpandDefaultStoreOnly = True Then
        Set xFld = xNameSpace.GetDefaultFolder(olFolderInbox)
        Set xFld = xFld.Parent
        Set xFlds = xFld.Folders
        LoopFolders xFlds, True
      Else
        LoopFolders xNameSpace.Folders, True
        LoopFolders xNameSpace.Folders, False
      End If
      DoEvents
      Set Application.ActiveExplorer.NavigationPane.CurrentModule = xModule
      Set Application.ActiveExplorer.CurrentFolder = xCurrFld
      Set xNameSpace = Nothing
      Set xModule = Nothing
      Set xCurrFld = Nothing
    End Sub
    
    Private Sub LoopFolders(Flds As Outlook.Folders, ByVal All As Boolean)
      Dim xFld As Outlook.MAPIFolder
      On Error Resume Next
      For Each xFld In Flds
        Select Case All
          Case True
            If xFld.DefaultItemType = olMailItem Then
              Set Application.ActiveExplorer.CurrentFolder = xFld
              DoEvents
              If xFld.Folders.Count > 0 Then
                LoopFolders xFld.Folders, All
              End If
            End If
          Case False
            Set Application.ActiveExplorer.CurrentFolder = xFld
            DoEvents
            If xFld.Folders.Count > 0 Then
              LoopFolders xFld.Folders, All
            End If
        End Select
      Next
    End Sub
  3. Sla de code op en sluit het Microsoft Visual Basic voor toepassingen venster.

Vanaf nu worden bij het herstarten van Outlook alle mappen automatisch uitgevouwen in Outlook.

Opmerkingen:

  • Deze VBA kan de samengevouwen zoekmappen niet openen bij het opnieuw opstarten van Outlook.
  • Om ervoor te zorgen dat het VBA-script correct functioneert, is het essentieel om uw macro-instellingen in Outlook aan te passen. Ga aub naar Dien in > Opties > Vertrouwenscentrum > Vertrouwenscentrum-instellingen > Macro-instellingenen selecteer de Schakel alle macro's in keuze. Met deze instelling kan het VBA-script zonder enige beperking worden uitgevoerd.

pijl blauw rechts bel Gerelateerde artikelen


Beste Office-productiviteitstools

Kutools for Outlook - Meer dan 100 krachtige functies om uw Outlook een boost te geven

🤖 AI Mail-assistent: Directe professionele e-mails met AI-magie: met één klik geniale antwoorden, perfecte toon, meertalige beheersing. Transformeer e-mailen moeiteloos! ...

???? Email Automation: Niet aanwezig (beschikbaar voor POP en IMAP)  /  Plan het verzenden van e-mails  /  Automatische CC/BCC volgens regels bij het verzenden van e-mail  /  Automatisch doorsturen (geavanceerde regels)   /  Begroeting automatisch toevoegen   /  Splits e-mails van meerdere ontvangers automatisch op in individuele berichten ...

📨 email management: Gemakkelijk e-mails herinneren  /  Blokkeer zwendel-e-mails van onderwerpen en anderen  /  Verwijder dubbele e-mails  /  Uitgebreid Zoeken  /  Consolideer mappen ...

📁 Bijlagen ProBatch opslaan  /  Batch losmaken  /  Batchcompressie  /  Automatisch opslaan   /  Automatisch loskoppelen  /  Automatisch comprimeren ...

???? Interface-magie: 😊Meer mooie en coole emoji's   /  Verhoog uw Outlook-productiviteit met weergaven met tabbladen  /  Minimaliseer Outlook in plaats van te sluiten ...

???? Wonderen met één klik: Beantwoord iedereen met inkomende bijlagen  /   Antiphishing-e-mails  /  🕘Toon de tijdzone van de afzender ...

👩🏼‍🤝‍👩🏻 Contacten en agenda: Batchcontacten toevoegen uit geselecteerde e-mails  /  Splits een contactgroep in individuele groepen  /  Verwijder verjaardagsherinneringen ...

Over 100 Eigenschappen Wacht op je verkenning! Klik hier om meer te ontdekken.

 

 

Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Just tried this on Microsoft® Outlook® for Microsoft 365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit and it was unsuccessful
This comment was minimized by the moderator on the site
Hi there,

Please go to File > Options > Trust Center > Trust Center Settings > Macro Settings. And select the Enable all macros option. After making this change, restart Outlook, the macro should then be operational.
This comment was minimized by the moderator on the site
Hi guys,

does this code also work for Microsoft outlook 365?
I have tried and tried again, but I get no results.
Thanks.
This comment was minimized by the moderator on the site
I couldn't get this macro to work either.
This comment was minimized by the moderator on the site
Hi there,
We've updated the code, please try it again. 🙂
Amanda
This comment was minimized by the moderator on the site
I cannot get this macro to work at all.  All folders in the Folder pane are not expanded at all.  I am using Outlook 2021.  Is there some instruction I missed?
This comment was minimized by the moderator on the site
Hi there,
We've updated the code, please try it again. 🙂
Amanda
This comment was minimized by the moderator on the site
Thank you so much.. It solved my problem. :)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations