Outlookの各色カテゴリのアイテム数をExcelにすばやくエクスポートする方法

今すぐ共有:

Outlook PSTファイルの各色カテゴリのアイテムの総数をすばやく取得したい場合は、この記事で公開されているVBAコードを使用できます。 便利なチェックのために、すべてのカウントをExcelファイルに直接エクスポートします。

Outlookの各色カテゴリのアイテム数をExcelにすばやくエクスポートする場合によっては、何らかの理由で、Outlookデータファイルの各色カテゴリに含まれるアイテムの数をカウントしたい場合があります。 一般に、インスタント検索を使用してカウントを行うことができます。 たとえば、最初に検索ボックスをクリックします。 次に、[検索]リボンの[分類]ボタンをクリックし、ドロップダウンリストから特定の色のカテゴリを選択します。 次に、[スコープ]リボングループで[すべてのOutlookアイテム]を選択します。 その後、検索が完了すると、選択したカラーカテゴリのすべてのアイテムが一覧表示されます。 これで、ステータスバーの左下隅にこれらの検索結果の数が表示されます。

間違いなく、色のカテゴリがたくさんある場合、これにより、XNUMXつずつ数えるのは非常に面倒になります。 したがって、この要件に応えて、ここでははるかに迅速な方法を明らかにします。 すべてのカウントをExcelファイルに直接エクスポートします。

Outlookの各色カテゴリのアイテム数をExcelにエクスポートする

  1. そもそも、starOutlookアプリケーション。
  2. 次に、「Alt + F11」キーボタンを押して、OutlookVBAエディターにアクセスします。
  3. 続く「MicrosoftVisualBasic for Applications」ウィンドウで、空のモジュールを開きます。
  4. 次に、次のVBAコードをこのモジュールウィンドウにコピーできます。
Public objDictionary As Object
Public objExcelApp As Excel.Application
Public objExcelWorkbook As Excel.Workbook
Public objExcelWorksheet As Excel.Worksheet
 
Sub ExportCountofItemsinEachColorCategories()
    Dim objCategories As Object
    Dim objCategory As Object
    Dim objPSTFile As Outlook.Folder
    Dim objFolder As Outlook.Folder
    Dim strExcelFile As String
 
    'Create a New Excel file
    Set objExcelApp = CreateObject("Excel.Application")
    Set objExcelWorkbook = objExcelApp.Workbooks.Add
    Set objExcelWorksheet = objExcelWorkbook.Sheets("Sheet1")
    objExcelWorksheet.Cells(1, 1) = "Color Category"
    objExcelWorksheet.Cells(1, 2) = "Count"
 
    'Find all the color categories
    Set objDictionary = CreateObject("Scripting.Dictionary")

    Set objCategories = Outlook.Application.Session.Categories
    For Each objCategory In objCategories
        objDictionary.Add objCategory.Name, 0
    Next
 
    Set objPSTFile = Outlook.Application.Session.PickFolder
 
    For Each objFolder In objPSTFile.Folders
        ProcessFolder objFolder
    Next
 
    'Save the new Excel file
    objExcelWorksheet.Columns("A:B").AutoFit
    strExcelFile = "E:\Outlook\Color Categories (" & Format(Now, "yyyy-mm-dd_hh-mm-ss") & ").xlsx"
    objExcelWorkbook.Close True, strExcelFile

    MsgBox "Complete!", vbExclamation
End Sub
 
Private Sub ProcessFolder(ByVal objCurrentFolder As Outlook.Folder)
    Dim objItem As Object
    Dim objSubFolder As Object
    Dim ArrayCategories As Variant
    Dim VarCategory As Variant
    Dim ArrayKey As Variant
    Dim ArrayItem As Variant
    Dim i As Long
    Dim nRow As Integer

    'Count the items in each color category via Dictionary object
    For Each objItem In objCurrentFolder.Items
        If objItem.Categories <> "" Then
           ArrayCategories = Split(objItem.Categories, ",")
           For Each VarCategory In ArrayCategories
               If objDictionary.Exists(VarCategory) = True Then
                  objDictionary.Item(VarCategory) = objDictionary.Item(VarCategory) + 1
               End If
          Next
        End If
    Next
 
    ArrayKey = objDictionary.Keys
    ArrayItem = objDictionary.Items
    nRow = 2
 
    'Input the information into the new Excel file
    For i = LBound(ArrayKey) To UBound(ArrayKey)
        objExcelWorksheet.Cells(nRow, 1) = ArrayKey(i)
        objExcelWorksheet.Cells(nRow, 2) = ArrayItem(i) & “ Items”
        nRow = nRow + 1
    Next
 
    'Process the subfolders recursively
    For Each objSubFolder In objCurrentFolder.Folders
        ProcessFolder objSubFolder
    Next
End Sub

VBAコード-Outlookの各色カテゴリのアイテムを数える

  1. その後、Outlookでマクロが許可されているかどうかを確認します。
  2. 最後に、試してみることができます。
  • まず、この新しいマクロでF5キーボタンを押します。
  • 次に、ソースPSTファイルを選択して「OK」をクリックする必要があります。
  • 「完了」というメッセージが表示されたら、ローカルドライブに移動し、Excelファイルを保存するための事前定義されたフォルダーを開くことができます。
  • Excelファイルを見つけて開きます。 次の画像のようになります。効果:各色カテゴリのアイテム数をExcelにエクスポート

Outlookが突然クラッシュした場合の対処方法

Outlookには複数の強力な機能がありますが、時間の経過とともにOutlookでさまざまな問題が発生する傾向があります。 たとえば、Outlookは時々クラッシュする可能性があります。 せいぜい、解像度tarOutlookを使用すると、問題を修正できるようになります。 最悪の場合、PSTデータの破損に直接つながる可能性があります。 その時、あなたは様々な手段を利用して PSTを修復する 最大のOutlookデータを取得するためのファイル。このデータについては、次のような経験豊富なツールに繰り返すことができます。 DataNumen Outlook Repair.

著者紹介:

Shirley Zhangは、のデータ復旧の専門家です。 DataNumen、Inc。は、以下を含むデータ復旧技術の世界的リーダーです。 SQL修復 と見通し修理ソフトウェア製品。 詳細については、次のWebサイトをご覧ください。 WWW。datanumen.com

今すぐ共有:

コメントは締め切りました。