Loncat ke daftar isi utama

Bagaimana cara mengekspor jumlah pesan prospek ke buku kerja Excel?

Biasanya, Anda dapat mengekspor pesan Outlook ke file Excel dengan menggunakan fitur Impor / Ekspor dengan cepat dan mudah. Tapi, pernahkah Anda mencoba menghitung item di semua folder akun Email tertentu Anda dan mengekspor hasil hitungan ke buku kerja Excel?

Ekspor jumlah pesan prospek ke buku kerja Excel dengan kode VBA


Ekspor jumlah pesan prospek ke buku kerja Excel dengan kode VBA

Kode VBA berikut dapat membantu Anda mengekspor hasil penghitungan dari semua folder di akun Email tertentu ke buku kerja Excel, lakukan seperti ini:

1. Tahan ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempel kode berikut di Modul Jendela.

Kode VBA: Ekspor item prospek dihitung ke buku kerja Excel:

Sub Export_CountOfItems_InEachFolder_toExcel()
    Dim xSourceFolder As Outlook.Folder, xSubFolder As Outlook.Folder
   Dim xFilePath As String
    Dim xExcelApp As Excel.Application
    Dim xWb As Excel.Workbook
    Dim xWs As Excel.Worksheet
    On Error Resume Next
    Set xExcelApp = New Excel.Application
    Set xWb = xExcelApp.Workbooks.Add
    Set xWs = xWb.Sheets(1)
    xWs.Cells(1, 1) = "Folder"
    xWs.Cells(1, 2) = "Count Items"
    Set xSourceFolder = Outlook.Application.Session.PickFolder
    If xSourceFolder = nill Then
        xWb.Close False
        xExcelApp.Quit
        Exit Sub
    End If
    For Each xSubFolder In xSourceFolder.Folders
        Call ProcessFolders(xWs, xSubFolder)
    Next
    xWs.Columns("A:B").AutoFit
    Set xShell = CreateObject("Shell.Application")
    Set xFolder = xShell.BrowseforFolder(0, "Select a Folder:", 0, 0)
   If TypeName(xFolder) = "Nothing" Then
        xWb.Close False
        xExcelApp.Quit
        Exit Sub
    End If
    Set xFolderItem = xFolder.Self
    xFilePath = xFolderItem.Path & "\"
    xFilePath = xFilePath & xSourceFolder.Name & "(" & Format(Now, "yyyy-mm-dd hh-mm-ss") & ").xlsx"
    xWb.Close True, xFilePath
    xExcelApp.Quit
    Set xShell = Nothing
    MsgBox "Complete!", vbExclamation, "Kutools for Outlook"
End Sub
Sub ProcessFolders(ByVal Ws As Worksheet, ByVal xCurFolder As Outlook.Folder)
    Dim xSubFld As Folder
    Dim xItemCount As Long
   Dim xRow As Integer
    xItemCount = xCurFolder.Items.Count
    xRow = Ws.UsedRange.Rows.Count + 1
    Ws.Cells(xRow, 1) = xCurFolder.FolderPath
    Ws.Cells(xRow, 2) = xItemCount
    If xCurFolder.Folders.Count > 0 Then
       For Each xSubFld In xCurFolder.Folders
           Call ProcessFolders(Ws, xSubFld)
       Next
    End If
End Sub

3. Dan, masih di Microsoft Visual Basic untuk Aplikasi window, klik Tools > Referensi untuk pergi ke Referensi-Proyek 1 kotak dialog, dan centang Perpustakaan Objek Microsoft Excel pilihan dari Referensi yang Tersedia kotak daftar, lihat tangkapan layar:

dokumen ekspor item menghitung 1

4. Lalu klik OK, lalu tekan F5 kunci untuk menjalankan kode ini, a Pilih Folder muncul, pilih akun Email yang ingin Anda ekspor jumlah itemnya, lihat tangkapan layar:

dokumen ekspor item menghitung 2

5. Lalu klik OK, dan satu lagi Jelajahi Folder ditampilkan, pilih folder untuk meletakkan file Excel, lihat tangkapan layar:

dokumen ekspor item menghitung 3

6. Terakhir, klik OK tombol, dan jumlah item di semua folder dari akun yang dipilih telah diekspor ke buku kerja Excel, Anda dapat membuka file Excel untuk melihat hasilnya, lihat tangkapan layar:

dokumen ekspor item menghitung 4


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 (5)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello, CETIN,
Maybe you forgot the step3 in this article, you should check the Microsoft Excel Object Library option in the Available References list box.
please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Sub ProcessFolders(ByVal Ws As Worksheet, ByVal xCurFolder As Outlook.Folder)

This line gives error ;

User -defined type not defined, after pressing F5
This comment was minimized by the moderator on the site
Thank for posting this Code works Exactly as written, Kudos
This comment was minimized by the moderator on the site
This Is Perfect, it worked exactly as it is written, thank you for posting this code
This comment was minimized by the moderator on the site
Doesn't work
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations