Snel stemstatistieken exporteren vanuit een Outlook-e-mail naar een Excel-werkblad

Als u een e-mail met stemknoppen hebt verzonden, wilt u, nadat de ontvangers u hun antwoorden hebben gestuurd, de stemstatistieken tellen en exporteren naar een Excel-werkblad. Dus in deze post, zullen we u leren hoe u dit snel kunt bereiken.

Outlook is zo krachtig dat het zelfs een "stemfunctie" biedt. Mijn vorige artikel "Bekwaam gebruik van MS Outlook om te stemmen”Heeft geleerd hoe het effectief te gebruiken. Ook most Na het stemmen kunt u de stemstatistieken om de een of andere reden exporteren naar een Excel-werkblad, bijvoorbeeld als u de statistieken wilt afdrukken. Maar Outlook ondersteunt dit standaard niet. Daarom zullen we u in het volgende leren hoe u dit als een kurk kunt realiseren.

Exporteer snel stemstatistieken van een Outlook-e-mail naar een Excel-werkblad

Exporteer stemstatistieken in een e-mail naar een Excel-werkblad

  1. Start vanaf het begin uw Outlook-applicatie.
  2. Vervolgens moet u op de toets "Alt + F11" drukken in het hoofdvenster van Outlook.
  3. Vervolgens moet u in het venster "Microsoft Visual Basic for Applications" "Microsoft Excel Object Library ”. Klik op "Extra"> "Referentie". Markeer vervolgens in het pop-upvenster het selectievakje voor het "Microsoft Excel Object Library 'en druk als laatste op' OK '.
  4. Daarna kunt u een nieuwe module invoegen of een niet in gebruik zijnde module openen.
  5. Kopieer en plak vervolgens de volgende VBA-codes in deze module.
Sub ExportVotingStatistics _Excel ()
    Dim objMail As Outlook.MailItem
    Dim objRecipient As Outlook.recipient
    Dim objVoteDictionary As Object
    Dim varVotingCounts As Variant
    Dim varVotingOptions As Variant
    Dim varVotingOption As Variant
    Dim i As Long
    Dim objExcelApp As Excel.Application
    Dim objExcelWorkbook As Excel.Workbook
    Dim objExcelWorksheet As Excel.Worksheet
    Dim nRow As Integer
 
    Set objMail = Application.ActiveExplorer.Selection(1)
 
    'Create a new excel worksheet
    Set objExcelApp = CreateObject("Excel.Application")
    Set objExcelWorkbook = objExcelApp.Workbooks.Add
    Set objExcelWorksheet = objExcelWorkbook.Sheets(1)
 
    'Fill in the predefined values
    With objExcelWorksheet
         .Cells.Font.Name = "Cambria"
         .Cells(1, 1) = "Voting Results for Email:"
         .Cells(1, 2) = Chr(34) & objMail.Subject & Chr(34)
         .Cells(3, 1) = "Voting Options"
         .Cells(3, 2) = "Voting Counts"
    End With
 
    Set objVoteDictionary = CreateObject("Scripting.Dictionary")
    'get the default voting options
    varVotingOptions = Split(objMail.VotingOptions, ";")
    'Add the voting responses to the dictionary
    For Each varVotingOption In varVotingOptions
        objVoteDictionary.Add varVotingOption, 0
    Next
    'Add a custom voting response - "No Reply"
    objVoteDictionary.Add "No Reply", 0
 
    'Process the all voting responses
    For Each objRecipient In objMail.Recipients
        If objRecipient.TrackingStatus = olTrackingReplied Then
           If objVoteDictionary.Exists(objRecipient.AutoResponse) Then
              objVoteDictionary.Item(objRecipient.AutoResponse) = objVoteDictionary.Item(objRecipient.AutoResponse) + 1
           Else
              objVoteDictionary.Add objRecipient.AutoResponse, 1
           End If
        Else
           objVoteDictionary.Item("No Reply") = objVoteDictionary.Item("No Reply") + 1
        End If
    Next
 
    'Get the voting options and vote counts
    varVotingOptions = objVoteDictionary.Keys
    varVotingCounts = objVoteDictionary.Items
 
    'Fill in the values in specific cells
    nRow = 4
    For i = LBound(varVotingOptions) To UBound(varVotingOptions)
        With objExcelWorksheet
             .Cells(nRow, 1) = varVotingOptions(i)
             .Cells(nRow, 2) = varVotingCounts(i)
        End With
        nRow = nRow + 1
    Next
 
    'Save the new Excel file
    objExcelWorksheet.Columns("A:B").AutoFit
    strExcelFile = "E:\Voting Results " & Format(Now, "YYYY-MM-DD hh-mm-ss") & ".xlsx"
    objExcelWorkbook.Close True, strExcelFile

    MsgBox "Complete!", vbExclamation
End Sub

VBA-code - Exporteer stemstatistieken van een Outlook-e-mail naar een Excel-werkblad

  1. Daarna kunt u voor gemakkelijke toegang de nieuwe macro beter toevoegen aan de werkbalk Snelle toegang.
  2. Uiteindelijk kun je het proberen.
  • Selecteer eerst een bron-e-mailbericht dat stemknoppen bevat.
  • Klik vervolgens op de macroknop in de werkbalk Snelle toegang.
  • Nadat deze macro is uitgevoerd, kunt u naar de vooraf gedefinieerde lokale map bladeren, waarin u een nieuwe Excel-werkmap ziet.
  • Open deze Excel-werkmap. Nu zie je de stemstatistieken, weergegeven als de onderstaande afbeelding:Geëxporteerde stemstatistieken

Niemand kan Outlook-fouten grondig voorkomen

Hoewel Outlook een verscheidenheid aan mogelijkheden biedt, is er niet zo'n functie om ons te helpen Outlook-fouten te voorkomen. Allerlei factoren kunnen Outlook-fouten veroorzaken. Als u bijvoorbeeld Outlook vaak niet correct afsluit, loopt u daar waarschijnlijk last van PST-corruptie​ In zo'n scenario heb je geen andere keuze dan een aantal krachtige tools te gebruiken om je PST-bestand te redden, zoals DataNumen Outlook Repair​ Het heeft veel complimenten verdiend vanwege het hoge herstelpercentage.

Auteur Introductie:

Shirley Zhang is een expert op het gebied van gegevensherstel in DataNumen, Inc., de wereldleider in technologieën voor gegevensherstel, waaronder corrupte mdf en Outlook-reparatiesoftwareproducten. Voor meer informatie bezoek www.datanumen.com

Reacties zijn gesloten.