Μετάβαση στο κύριο περιεχόμενο

Πώς να εξαγάγετε τη δομή φακέλων από το Outlook στο Excel;

Αυτό το άρθρο, θα παρουσιάσω τον τρόπο εξαγωγής της δομής φακέλων ενός λογαριασμού από το Outlook στο αρχείο Excel. Αποκτήστε το με τις λεπτομέρειες αυτού του άρθρου.

Εξαγωγή δομής φακέλου ενός λογαριασμού από το Outlook στο Excel χρησιμοποιώντας τον κώδικα VBA


Εξαγωγή δομής φακέλου ενός λογαριασμού από το Outlook στο Excel χρησιμοποιώντας τον κώδικα VBA

Ο παρακάτω κώδικας VBA μπορεί να σας βοηθήσει, κάντε τα παρακάτω βήματα:

1. Ενεργοποιήστε το Excel και κρατήστε πατημένο το ALT + F11 για να ανοίξετε το Microsoft Visual Basic για εφαρμογές παράθυρο.

2. Κλίκ Κύριο θέμα > Μονάδα μέτρησηςκαι επικολλήστε τον ακόλουθο κώδικα στο Μονάδα μέτρησης Παράθυρο.

Κωδικός VBA: Εξαγωγή δομής φακέλου ενός λογαριασμού από το Outlook στο Excel:

Dim xExcelApp As Excel.Application
Dim xWb As Excel.Workbook
Dim xWs As Excel.Worksheet
Dim xMainFolderCount As Long
Sub OutlookExportFolderStructureToExcel()
    Dim xFolder As Folder
    Dim xExcelFile As String
    Dim xFileDialog As FileDialog
    On Error Resume Next
    Set xFolder = Outlook.Application.Session.PickFolder
    If xFolder Is Nothing Then Exit Sub
    Set xExcelApp = New Excel.Application
    Set xWb = xExcelApp.Workbooks.Add
    Set xWs = xWb.Sheets(1)
    With xWs.Range("A1", "A1")
         .Value = "Folder Structure"
         .Font.Size = 14
         .Font.Bold = True
    End With
    xMainFolderCount = Len(xFolder.FolderPath) - Len(Replace(xFolder.FolderPath, "\", "")) + 1
    Call ExportToExcel(xFolder.FolderPath, xFolder.Name)
    Call ProcessFolders(xFolder.Folders)
    xWs.Columns("A").AutoFit
    Set xFileDialog = xExcelApp.FileDialog(msoFileDialogSaveAs)
    With xFileDialog
        .AllowMultiSelect = False
        .FilterIndex = 1
        If .Show = 0 Then
            xWb.Close False
            xExcelApp.Quit
            Set xExcelApp = Nothing
            Exit Sub
        End If
        xExcelFile = .SelectedItems.Item(1)
    End With
    xWb.Close True, xExcelFile
    MsgBox "Export complete!", vbExclamation, "Kutools for Outlook"
End Sub

Sub ProcessFolders(ByVal xFlds As Folders)
    Dim xSubFolder As Folder
    For Each xSubFolder In xFlds
        If xSubFolder.Name <> "Conversation Action Settings" And xSubFolder.Name <> "Quick Step Settings" Then
           Call ExportToExcel(xSubFolder.FolderPath, xSubFolder.Name)
           Call ProcessFolders(xSubFolder.Folders)
        End If
    Next
End Sub

Sub ExportToExcel(ByRef xFolderPath As String, xFolderName As String)
    Dim i, n As Long
    Dim xPrefix As String
    Dim xLastRow As Integer
    i = Len(xFolderPath) - Len(Replace(xFolderPath, "\", "")) - xMainFolderCount
    For n = 0 To i
        xPrefix = xPrefix & "-"
    Next
    xFolderName = xPrefix & xFolderName
    xLastRow = xWs.UsedRange.Rows.Count + 1
    xWs.Range("A" & xLastRow) = xFolderName
End Sub

3. Ακόμα στο Microsoft Visual Basic για εφαρμογές παράθυρο, κάντε κλικ στην επιλογή Εργαλεία > αναφορές για να μεταβείτε στο Αναφορές-Έργο 1 πλαίσιο διαλόγου και επιλέξτε Βιβλιοθήκη αντικειμένων του Microsoft Excel Επιλογή από το Διαθέσιμες αναφορές πλαίσιο λίστας, δείτε το στιγμιότυπο οθόνης:

doc δομή φακέλου εξαγωγής για να υπερέχει 1

4. Στη συνέχεια κάντε κλικ στο κουμπί OK και πατήστε F5 κλειδί για την εκτέλεση αυτού του κώδικα, a Επιλογή φακέλου εμφανίζεται το παράθυρο διαλόγου, επιλέξτε τον λογαριασμό email που θέλετε να εξαγάγετε τη δομή του φακέλου του, δείτε το στιγμιότυπο οθόνης:

doc δομή φακέλου εξαγωγής για να υπερέχει 2

5. Και μετά, κάντε κλικ στο OK κουμπί, α Αποθήκευση αρχείου εμφανίζεται το παράθυρο, προσδιορίστε μια θέση και το όνομα αρχείου για αυτό το εξαγόμενο αρχείο, δείτε το στιγμιότυπο οθόνης:

doc δομή φακέλου εξαγωγής για να υπερέχει 3

6. Επιτέλους, κάντε κλικ στο κουμπί Αποθήκευση κουμπί και μπορείτε να μεταβείτε στο συγκεκριμένο βιβλίο εργασίας excel που έχετε αποθηκεύσει για να δείτε τη δομή του εξαγόμενου φακέλου, δείτε το στιγμιότυπο οθόνης:

doc δομή φακέλου εξαγωγής για να υπερέχει 4

 


Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

Kutools για το Outlook - Πάνω από 100 ισχυρές δυνατότητες για υπερφόρτιση του Outlook σας

🤖 Βοηθός αλληλογραφίας AI: Άμεσα επαγγελματικά email με μαγεία AI -- με ένα κλικ για ιδιοφυείς απαντήσεις, τέλειος τόνος, πολυγλωσσική γνώση. Μεταμορφώστε τα email χωρίς κόπο! ...

📧 Αυτοματοποίηση ηλεκτρονικού ταχυδρομείου: Εκτός γραφείου (Διαθέσιμο για POP και IMAP)  /  Προγραμματισμός αποστολής email  /  Αυτόματο CC/BCC βάσει κανόνων κατά την αποστολή email  /  Αυτόματη προώθηση (Σύνθετοι κανόνες)   /  Αυτόματη προσθήκη χαιρετισμού   /  Διαχωρίστε αυτόματα τα μηνύματα ηλεκτρονικού ταχυδρομείου πολλών παραληπτών σε μεμονωμένα μηνύματα ...

📨 Διαχείριση e-mail: Εύκολη ανάκληση email  /  Αποκλεισμός απάτης email από υποκείμενα και άλλους  /  Διαγραφή διπλότυπων μηνυμάτων ηλεκτρονικού ταχυδρομείου  /  Προχωρημένη Αναζήτηση  /  Ενοποίηση φακέλων ...

📁 Συνημμένα ProΜαζική αποθήκευση  /  Αποσύνδεση παρτίδας  /  Συμπίεση παρτίδας  /  Αυτόματη αποθήκευση   /  Αυτόματη απόσπαση  /  Αυτόματη συμπίεση ...

🌟 Διασύνδεση Magic: 😊Περισσότερα όμορφα και δροσερά emojis   /  Ενισχύστε την παραγωγικότητά σας στο Outlook με προβολές με καρτέλες  /  Ελαχιστοποιήστε το Outlook αντί να κλείσετε ...

???? Με ένα κλικ Wonders: Απάντηση σε όλους με εισερχόμενα συνημμένα  /   Email κατά του phishing  /  🕘Εμφάνιση ζώνης ώρας αποστολέα ...

👩🏼‍🤝‍👩🏻 Επαφές & Ημερολόγιο: Μαζική προσθήκη επαφών από επιλεγμένα μηνύματα ηλεκτρονικού ταχυδρομείου  /  Διαχωρίστε μια ομάδα επαφής σε μεμονωμένες ομάδες  /  Κατάργηση υπενθυμίσεων γενεθλίων ...

Διανεμήθηκαν παραπάνω από 100 Χαρακτηριστικά Περιμένετε την εξερεύνηση σας! Κάντε κλικ εδώ για να ανακαλύψετε περισσότερα.

 

 

 

Comments (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I cannot access the toolbox to check Microsoft Excel Object Library option from the Available References list box,a
The toolbox icon is selected but greyed out

thanks
This comment was minimized by the moderator on the site
You additionally need to select "Microsoft Outlook 16.0 Object Library" as a reference.
This comment was minimized by the moderator on the site
Hello,
thank you for your fast response. I think, i’ve now set all necessary options. But i can’t find the „Apply macro security settings to installed add-ins“
I would like to send some screenshots, but can't find how to on this page.
Best regards Erich Hackel
This comment was minimized by the moderator on the site
Hello, Erich,
If you can't find the "Apply macro security settings to installed add-ins" option, please view the below screenshot:

https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-option-setting.png
This comment was minimized by the moderator on the site
Hallo,
ich habe exakt den gleichen Fehler wie Jörg. Ich habe Office Professional Plus 2021 in Deutsch installiert.
Punkt 3 finde ich unter Extras - Verweise. Auch bei mir war die "MS Excel 16.0 Object Library" bereits aktiviert, zusätzlich auch noch "Visual Basic For Applications", "MS Office 16.0 Object Library" und "OLE Automation".
Beim Ausführen ebenfalls der "Fehler beim Kompilieren", der Hilfe-Button verrät dann noch "Der Administrator Ihrer Organisation hat den für die Verwendung dieser Funktion erforderlichen Dienst deaktiviert."
Aber welcher ist das und wo / wie kann man ihn aktivieren???
This comment was minimized by the moderator on the site
Hello, Erich
May be you should enable all macros setting, please do as this:
In your Outlook, please click File > Options > Trust Center > Trust Center Settings > Macro Settings, and then check Enable all macros and Apply macro security settings to installed add-ins options.

After finishing this setting, please restart the Outlook.

Please try, thank you!
This comment was minimized by the moderator on the site
I'm using Outlook from MS Office 2019 Pro plus 64bit in German always latest version. How can I send a picture?
This comment was minimized by the moderator on the site
Hello,
May be you should enable all macros setting, please do as this:
In your Outlook, please click File > Options > Trust Center > Trust Center Settings > Macro Settings, and then check Enable all macros and Apply macro security settings to installed add-ins options.
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-option-setting.png

After finishing this setting, please restart the Outlook.

Please try, thank you!
This comment was minimized by the moderator on the site
Hi, it looks like my answer wasn't send. I tested the script again. Same error message. I do not miss step3. That topic was/is already active. I disabled and later enabled it again. Same result. It always stops at line 40. Any idea?
This comment was minimized by the moderator on the site
Hello, Jörg Normann

The code works well in my Outlook, which Outlook version you used? Or you can upload the error screenshot here.
Thank you!
This comment was minimized by the moderator on the site
Hello, I did it the way as described. Step 3 (MS Excel 16.0 Object Library) was allready active. I disabled and lated enabled it again. When I click F5 there is no question for a folder to store. I get an error message: Error in line 40: "Fehler beim Kompilieren: Benutzerdefinierter Typ nicht definiert".
This comment was minimized by the moderator on the site
Hallo, bei mir führt der Code beim Ausführen zu einem Fehler in Zeile 40 "Fehler beim Kompilieren: Benutzerdefinierter Typ nicht definiert". Und anders als in der Beschreibung wir bei mir in Punkt 4. weder nach dem Ordner noch nach dem Mail-Konto gefragt.
This comment was minimized by the moderator on the site
Hello, Jörg.N
If you get the error prompt message, please check if you missed the step3 in this article.
You should follow the steps in the article step by step, if there is still problem, please comment here.
Thank you!
This comment was minimized by the moderator on the site
This code is great and works great, thank you.
What would maker even extra great would be if it could show the sizes (in bytes, kilobytes, megabytes, petabytes, whatever) and even possibly the item count for each folder.
:)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations