Loncat ke daftar isi utama

Bagaimana cara memperluas semua folder secara otomatis saat memulai Outlook?

Biasanya, saat Anda memperluas atau menciutkan folder di Panel Navigasi Outlook dan kemudian menutup program, folder tersebut akan mempertahankan status diperluas atau diciutkan setelah membuka kembali Outlook. Namun, bagaimana jika Anda ingin semua folder diperluas secara otomatis setiap kali Anda memulai Outlook? Artikel ini memberikan solusi VBA untuk mencapai hal tersebut.

Perluas semua folder secara otomatis saat memulai Outlook menggunakan VBA

Tab Office - Aktifkan Pengeditan dan Penjelajahan dengan Tab di Microsoft Office, Membuat Pekerjaan Menjadi Mudah
Kutools for Outlook - Tingkatkan Outlook dengan 100+ Fitur Lanjutan untuk Efisiensi Unggul
Tingkatkan Outlook 2021 - 2010 atau Outlook 365 Anda dengan fitur-fitur canggih ini. Nikmati uji coba gratis 60 hari yang komprehensif dan tingkatkan pengalaman email Anda!

panah gelembung kanan biru Perluas semua folder secara otomatis saat memulai Outlook menggunakan VBA

Panduan ini akan menunjukkan cara menggunakan skrip VBA untuk secara otomatis memperluas semua folder di Panel Navigasi setiap kali Anda meluncurkan Outlook. Ikuti langkah-langkah berikut untuk mengimplementasikan skrip VBA:

  1. Tekan Alt + F11 tombol secara bersamaan untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.
  2. Pilih proyek 1 dan Objek Microsoft Outlook dalam Project panel, klik dua kali untuk membuka Sesi Pandangan ini jendela, lalu tempel kode VBA di bawah ini ke dalamnya.

    VBA: Secara otomatis memperluas semua folder di Outlook

    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. Simpan kode dan tutup Microsoft Visual Basic untuk Aplikasi jendela.

Mulai sekarang, saat memulai ulang Outlook, semua folder akan diperluas secara otomatis di Outlook.

Catatan:

  • VBA ini tidak dapat membuka folder pencarian yang diciutkan saat memulai ulang Outlook.
  • Untuk memastikan skrip VBA berfungsi dengan benar, penting untuk menyesuaikan pengaturan makro Anda di Outlook. Silakan pergi ke File > Opsi > Trust Center > Pengaturan Pusat Kepercayaan > Pengaturan Makro, dan pilih Aktifkan semua makro pilihan. Pengaturan ini memungkinkan skrip VBA berjalan tanpa batasan apa pun.

panah gelembung kanan biru Artikel terkait


Alat Produktivitas Kantor Terbaik

Kutools untuk Outlook - Lebih dari 100 Fitur Canggih untuk Meningkatkan Outlook Anda

🤖 Asisten Surat AI: Email profesional instan dengan keajaiban AI--satu klik untuk mendapatkan balasan jenius, nada sempurna, penguasaan multibahasa. Ubah email dengan mudah! ...

📧 Email Otomatis: Di Luar Kantor (Tersedia untuk POP dan IMAP)  /  Jadwal Kirim Email  /  Auto CC/BCC Sesuai Aturan Saat Mengirim Email  /  Penerusan Otomatis (Aturan Lanjutan)   /  Tambah Salam Otomatis   /  Secara Otomatis Membagi Email Multi-Penerima menjadi Pesan Individual ...

📨 email Management: Mengingat Email dengan Mudah  /  Blokir Email Penipuan berdasarkan Subjek dan Lainnya  /  Hapus Email Duplikat  /  Pencarian  /  Konsolidasi Folder ...

📁 Lampiran ProPenyimpanan Batch  /  Pelepasan Batch  /  Kompres Batch  /  Penyimpanan otomatis   /  Lepaskan Otomatis  /  Kompres Otomatis ...

🌟 Antarmuka Ajaib: 😊Lebih Banyak Emoji Cantik dan Keren   /  Tingkatkan Produktivitas Outlook Anda dengan Tampilan Tab  /  Minimalkan Outlook Daripada Menutup ...

👍 Keajaiban sekali klik: Balas Semua dengan Lampiran Masuk  /   Email Anti-Phishing  /  🕘Tampilkan Zona Waktu Pengirim ...

👩🏼‍🤝‍👩🏻 Kontak & Kalender: Batch Tambahkan Kontak Dari Email yang Dipilih  /  Bagi Grup Kontak menjadi Grup Individual  /  Hapus Pengingat Ulang Tahun ...

Lebih 100 Fitur Tunggu Eksplorasi Anda! Klik Di Sini untuk Menemukan Lebih Banyak.

 

 

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