Outlook Meeting Tracking Export
Recently I was planning an event using my Outlook calendar at work. I needed to share the list of users who had accepted the outlook invitation with my fellow event planners. Unfortunately I couldn't find a way to do this in outlook without taking screen shots of the list
I found a website where someone had written a macro to export the list in word.
http://www.outlookcode.com/codedetail.aspx?id=37
The code didn't work in Office 2007 so I tweaked it and decided to take it one step further. I set it to export my list to Excel, instead of word, where I could quickly sort by name or acceptance.
If you have never created a macro before this may be a little intimidating but here's some easy instructions I got from Google Groups
- Copy the code below
- Open Outlook
- Press your <ALT>+<F11> (This opens the Microsoft Visual Basic - VbaProject.OTM)
- On the menu across the top select "Insert"
- Select "Module"
- In the blank window on the right, PASTE the code you copied
- Select "File"
- Select "Close and Return to Microsoft Outlook"
- Right click on your Tool menu (in the gray part where the buttons are)
- Select "Customize..."
- Click on the "Commands" tab
- Select "Macros" from the Categories
- Click on "Project1.PrintAapptAttendee" and drag it to your toolbar
and Drop it (You have to drop it ON the toolbar not in the gray
blank area but next to something like the yellow question mark icon) - Close the Customize window.
Now try to use this "Macro"
- Open an appointment that has attendees in it
- Click on the "Project1.PrintAapptAttendee" button that you put on your toolbar.
- Wait a moment for Word to open and show you your appointment with all of the attendees and how they responded to the invitation
Code:
Sub PrintAapptAttendee()
' Gather data from an opened appointment and print to
' Excel. This provides a way to print the attendee list with their
' response, which Outlook will not do on its own.
' Set up Outlook
Dim objApp As Outlook.Application
Dim objItem As Object
Dim objSelection As Selection
Dim objAttendees As Outlook.Recipients
Dim objAttendeeReq As String
Dim objAttendeeOpt As String
Dim objOrganizer As String
Dim dtStart As Date
Dim dtEnd As Date
Dim strSubject As String
Dim strLocation As String
Dim strNotes As String
Dim strMeetStatus As String
Dim strUnderline As String ' Horizontal divider line
' Set up Excel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
'Create the header and set the background color as yellow
objExcel.Cells(1, 1).Value = "Attendee"
objExcel.Cells(1, 1).Interior.ColorIndex = 6
objExcel.Cells(1, 2).Value = "Response"
objExcel.Cells(1, 2).Interior.ColorIndex = 6
objExcel.Cells(1, 3).Value = "Req/Opt"
objExcel.Cells(1, 3).Interior.ColorIndex = 6
On Error Resume Next
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.ActiveInspector.CurrentItem
Set objSelection = objApp.ActiveExplorer.Selection
Set objAttendees = objItem.Recipients
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
Set objExcel = CreateObject("Excel.Application")
End If
strUnderline = String(60, "_") ' use 60 underline characters
On Error GoTo EndClean:
' check for user problems with none or too many items open
Select Case objSelection.Count
Case 0
MsgBox "No appointment was opened. Please opten the appointment to print."
GoTo EndClean:
Case Is > 1
MsgBox "Too many items were selected. Just select one!!!"
GoTo EndClean:
End Select
' Is it an appointment
If objItem.Class <> 26 Then
MsgBox "You First Need To open The Appointment to Print."
GoTo EndClean:
End If
' Get the data
dtStart = objItem.Start
dtEnd = objItem.End
strSubject = objItem.Subject
strLocation = objItem.Location
strNotes = objItem.Body
objOrganizer = objItem.Organizer
objAttendeeReq = ""
objAttendeeOpt = ""
' Get The Attendee List
For x = 1 To objAttendees.Count
strMeetStatus = ""
Select Case objAttendees(x).MeetingResponseStatus
Case 0
strMeetStatus = "No Response"
Case 1
strMeetStatus = "Organizer"
Case 2
strMeetStatus = "Tentative"
Case 3
strMeetStatus = "Accepted"
Case 4
strMeetStatus = "Declined"
End Select
If objAttendees(x).Type = olRequired Then
objExcel.Cells(x + 1, 1).Value = objAttendees(x).Name
objExcel.Cells(x + 1, 2).Value = strMeetStatus
objExcel.Cells(x + 1, 3).Value = "Required"
Else
objExcel.Cells(x + 1, 1).Value = objAttendees(x).Name
objExcel.Cells(x + 1, 2).Value = strMeetStatus
objExcel.Cells(x + 1, 3).Value = "Optional"
End If
RowCount = RowCount + 1
Next
'Sort Worksheet
objExcel.Worksheets("Sheet1").Range("B2").Sort _
Key1:=objExcel.Worksheets("Sheet1").Columns("B"), _
Header:=xlGuess
objExcel.Worksheets("Sheet1").Range("A2").Sort _
Key1:=objExcel.Worksheets("Sheet1").Columns("B"), _
Header:=xlGuess
objExcel.Worksheets("Sheet1").Range("C2").Sort _
Key1:=objExcel.Worksheets("Sheet1").Columns("B"), _
Header:=xlGuess
EndClean:
Set objApp = Nothing
Set objItem = Nothing
Set objSelection = Nothing
Set objAttendees = Nothing
Set objExcel = Nothing
Set objxls = Nothing
Set excelRng = Nothing
Set wordPara = Nothing
End Sub
---->UPDATE (9/19/08): Please note you are using this macro at your own risk.
Many people were complaining that they could only run the item once and then it stopped working. I did some research and it turn outs that Outlook disables all "untrusted" Macros.
To get this to run more than once you will need to go to:
Tools > Trust Center and Macro Security > and change the radio button to "Warning for all macros"
You will need to close outlook completely (make sure it's not running as a background task) then reopen it.
You will receive a warning each time you run this macro but it should still work.
33 Comments:
This worked Great, thanks!!!!!!!!!
I used the script, but it only worked one time. I had to delete the macro and reload it for it to work again. Any suggestions?
This worked very well for me, too, but for one user who has a longer list of attendees, it worked the first time, then stalled out on the second try. We closed Excel, closed Outlook, even tried to delete the macro and reinstall it, but we get no more results on this user's machine. It's as if it was good for one application only. Any ideas?
We're using Outlook 2007 and ran this macro. It worked perfectly, then ran it again. Nothing happened. We closed Outlook, Excel and reinstalled the macro. Then the Tracking option disappeared from the original calendar appointment! Help! We can't seem to get it back.
Works beautifully for me time after time. I love you!
It does work consistently; however, in Outlook 2007, there are a few steps missing. When you open the appointment, you have to click on the tracking tab, then press ALT+F8 and run the macro. WORKS EVERYTIME! Promise!
It doesn't seem to work for me. the Excel opens but it doesn't populate anything. My macro security is set to medium. what else can i do?
That is fantastic! Thank you
The code does not work for me. It opens Excel and populates three headers [Attendee, Response, Req/Opt] with highlighted background, but that is it. There is no further data. I am working in Outlook 2003. Any suggestions please?
You are such a life saver!!! Thank you so much!!!
Thanks guy...
This is really a great piece!
This is fabulous, thank you!!
Thank you - this is very useful!
Thank you so much. I needed to get the email addresses as well. I modified the script to do so:
' . . . rest of file above
objExcel.Cells(x + 1, 1).Value = objAttendees(x).Name
objExcel.Cells(x + 1, 2).Value = strMeetStatus
objExcel.Cells(x + 1, 3).Value = "Optional"
End If
'New line to add fourth column with email addresses.
objExcel.Cells(x + 1, 4).Value = objAttendees(x).Address
RowCount = RowCount + 1
Next
'File continues below . . .
It works pretty well, except that internal attendees have Microsoft's internal email address format (X.400?) rather than SMTP styles addresses.
Brilliant! Wish there was a way to create a Macro button to run it from an appointment without having to use Atl F8
This worked very well! Thanks, you saved me several hours work.
Thanks, it worked for me, even if it put the headers on one page and the results in another one. I guess that's because I had Excel open before running the macro. I tried closing Excel, running the macro again and it would then put everything as expected (Headers + Data in same book). THANK YOU!
in outlook 2003 it works fine for me if i dont have excel open already. would be great if you could leave current work open. If anybody has a fix to that please post
Im on Off2007, works well provided that you dont have Excel previously open.
Hello,
first of all - i'm not a programmer - i can only Google :-)
for me the original script didn't work - excel workbook was created but never filled in any data.
I did some research and found, that maybe the focus on the excel file was lost while the script is running and therefore no data could be added.
I did some changes:
- Add some lines to have dedicated "sheet" values
- Add some lines to see if the person is an Active Directory account or has an external SMTP address
Note: For me it was usefull to have also the SMPT address within the Excel sheet so i can match another list
- Add a function to get the SMTP address out of the Active Directory via LDAP by the legacyExchangeDN
I hope this script will help others - the original one was a big step into solving my problem.
I tested the script with OL2003 - no guarantee that it will work and try it on your own risk!!!!
############################################################
Sub PrintAapptAttendee()
' Gather data from an opened appointment and print to
' Excel. This provides a way to print the attendee list with their
' response, which Outlook will not do on its own.
' Set up Outlook
Dim objApp As Outlook.Application
Dim objItem As Object
Dim objSelection As Selection
Dim objAttendees As Outlook.Recipients
Dim objAttendeeReq As String
Dim objAttendeeOpt As String
Dim objOrganizer As String
Dim dtStart As Date
Dim dtEnd As Date
Dim strSubject As String
Dim strLocation As String
Dim strNotes As String
Dim strMeetStatus As String
Dim strUnderline As String ' Horizontal divider line
Dim objExcelApp
Dim objExcelBook
Dim objExcelSheets
Dim objExcelSheet
Dim objExcelRange
Dim oExcel As Excel.Application
Dim owb As Excel.Workbook
Dim oWS As Excel.Worksheet
Dim var As String
Dim SMTPAdr
' Set up Excel
Set objExcel = CreateObject("Excel.Application")
Set oExcel = New Excel.Application
oExcel.Visible = True
Set owb = oExcel.Workbooks.Add
Set oWS = owb.Worksheets("Sheet1")
'Create the header and set the background color as yellow
oWS.Cells(1, 1).Value = "Attendee"
oWS.Cells(1, 1).Interior.ColorIndex = 6
oWS.Cells(1, 2).Value = "Response"
oWS.Cells(1, 2).Interior.ColorIndex = 6
oWS.Cells(1, 3).Value = "Req/Opt"
oWS.Cells(1, 3).Interior.ColorIndex = 6
oWS.Cells(1, 4).Value = "SMTP"
oWS.Cells(1, 4).Interior.ColorIndex = 6
On Error Resume Next
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.ActiveInspector.CurrentItem
Set objSelection = objApp.ActiveExplorer.Selection
Set objAttendees = objItem.Recipients
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
Set objExcel = CreateObject("Excel.Application")
End If
strUnderline = String(60, "_") ' use 60 underline characters
On Error GoTo EndClean:
' check for user problems with none or too many items open
Select Case objSelection.Count
Case 0
MsgBox "No appointment was opened. Please opten the appointment to print."
GoTo EndClean:
Case Is > 1
MsgBox "Too many items were selected. Just select one!!!"
GoTo EndClean:
End Select
' Is it an appointment
If objItem.Class <> 26 Then
MsgBox "You First Need To open The Appointment to Print."
GoTo EndClean:
End If
' Get the data
dtStart = objItem.Start
dtEnd = objItem.End
strSubject = objItem.Subject
strLocation = objItem.Location
strNotes = objItem.Body
objOrganizer = objItem.Organizer
objAttendeeReq = ""
objAttendeeOpt = ""
' Get The Attendee List
For x = 1 To objAttendees.Count
strMeetStatus = ""
Select Case objAttendees(x).MeetingResponseStatus
Case 0
strMeetStatus = "No Response"
Case 1
strMeetStatus = "Organizer"
Case 2
strMeetStatus = "Tentative"
Case 3
strMeetStatus = "Accepted"
Case 4
strMeetStatus = "Declined"
End Select
If objAttendees(x).Type = olRequired Then
var = objAttendees(x).Address
oWS.Cells(x + 1, 1).Value = objAttendees(x).Name
oWS.Cells(x + 1, 2).Value = strMeetStatus
oWS.Cells(x + 1, 3).Value = "Required"
SMTPAdr = InStr(1, objAttendees(x).Name, "@", 1)
If SMTPAdr = False Then
var = getMail(var)
End If
oWS.Cells(x + 1, 4).Value = var
Else
var = objAttendees(x).Address
oWS.Cells(x + 1, 1).Value = objAttendees(x).Name
oWS.Cells(x + 1, 2).Value = strMeetStatus
oWS.Cells(x + 1, 3).Value = "Optional"
SMTPAdr = InStr(1, objAttendees(x).Name, "@", 1)
If SMTPAdr = False Then
var = getMail(var)
End If
oWS.Cells(x + 1, 4).Value = var
End If
RowCount = RowCount + 1
Next
'Sort Worksheet
objExcel.Worksheets("Sheet1").Range("B2").Sort _
Key1:=objExcel.Worksheets("Sheet1").Columns("B"), _
Header:=xlGuess
objExcel.Worksheets("Sheet1").Range("A2").Sort _
Key1:=objExcel.Worksheets("Sheet1").Columns("B"), _
Header:=xlGuess
objExcel.Worksheets("Sheet1").Range("C2").Sort _
Key1:=objExcel.Worksheets("Sheet1").Columns("B"), _
Header:=xlGuess
EndClean:
Set objApp = Nothing
Set objItem = Nothing
Set objSelection = Nothing
Set objAttendees = Nothing
Set objExcel = Nothing
Set objxls = Nothing
Set excelRng = Nothing
Set wordPara = Nothing
End Sub
'This function matches the legacyExchangeDN to the corresponding SMTP E-Mail address from AD is existing
Function getMail(legacyEDN As String)
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strCN
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
'Note: Please remove the ! with < and ? with > within the next line!!!!
strBase = "!GC://DC=Your-Domain, DC=net?"
' Filter on user objects.
strFilter = "(&(objectCategory=person)(objectClass=user)(legacyExchangeDN=" & legacyEDN & "))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName,cn,DistinguishedName,displayName,mail"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
valueResult = adoRecordset.RecordCount
Set adoRecordset = adoCommand.Execute
If valueResult = 0 Then
strMail = "no SMTP-address found"
End If
If valueResult = 1 Then
strMail = adoRecordset.Fields("mail").Value
End If
If valueResult > 1 Then
' If valueResult > 1 Then
' ' Enumerate the resulting recordset.
' Do Until adoRecordset.EOF
' ' Retrieve values and display.
' If (InStr(1, Header, adoRecordset.Fields("mail").Value, vbBinaryCompare)) Then
' strMail = adoRecordset.Fields("mail").Value
' Else
' strMail = "no unique SMTP-address found"
' End If
' 'Move to the next record in the recordset.
' adoRecordset.MoveNext
' Loop
'End If
strMail = "Display name not unique"
End If
getMail = strMail
' Clean up.
adoRecordset.Close
adoConnection.Close
End Function
Thank you so much... this is a fantastic tool and has saved me so many hours! You're a doll, thanks.
brilliant, thank you! -shawn
Ummm... I can't get the Excel version to get past this line:
Dim oExcel As Excel.Application
What do I need to do to make this run?
Thanks!
Des
I as well can not get past the Excel "Dim oExcel As Excel.Application" section of the code. The original code at the top of this thread worked until the acceptance list was too large, so it timed out. So I tried the last code to add all the other features as well, and now I am stuck.
Worked great! Thank you so much for making a daunting task easy.
In one site I found nice tool-viewer pst file,
it has many features and as far as I know has free status,program helped me many times,it will help you to restore your data from files with *.pst and *.ost extension,tool will work under all supported versions of Microsoft Windows operating system, as well as with Microsoft Outlook,can retrieve all contents as a number of files in *.vcf, *.txt and *.eml formats,will extract thousands of different files, that will be placed into any folder, upon your choice,converting of recovered data into a *.pst file, that can be opened by any mail client or viewer .pst file, compatible with Microsoft Outlook, file size will not exceed 1Gb.
Yesterday I received some mails and I was afraid because it were damaged.But to my surprise friend recommended next application-outlook recovery software.It helped me very fast and it is free as far as I know,moreover utility save the recovered information as files with the *.pst extension.
It looks good but it only pastes the headings into excel not the meeting attendees and their responses - Any ideas what I need to change to get that info?
My collegues and I we thought that it would be useful to have the tracking information right into the body of the appointment, so when you print the appointment you can print also the tracking info.
The easiest way to go would be to put the macro into a module, then add a button on the stardard toolbar. This macro adds the tracking info to the appointment's body. Then you can save the info inside the body or not. Also you can delete this info at a later time.
Have fun with it!
The code is in another post because of the lenght limitation. Sorry!
Part 1:
Sub SendAppointmentResponsesToBody()
' usage: open an appointment from your calender and run the script - it will collect tracking information
' and append it to the appointment's body allowing the user to print / save it.
Dim myStatus As String, myName As String, myVersion As String
myName = "SendAppointmentResponsesToBody"
myVersion = "v.1.0.0.1" '<<------increment here
myCopyright = "©2009 Freeware"
' initialize
Dim objApp As Outlook.Application
Set objApp = CreateObject("Outlook.Application")
Dim objItem As Object
Set objItem = objApp.ActiveInspector.CurrentItem
Dim objSelection As Selection
Set objSelection = objApp.ActiveExplorer.Selection
Dim objAttendees As Outlook.Recipients
Set objAttendees = objItem.Recipients
Dim strUnderline As String ' Horizontal divider line
strDivider = "============================================================================"
On Error GoTo EndClean:
' check for user problems with no or too many appointment(s) open
Select Case objSelection.Count
Case 0
msgPrompt = myName & " - " & myVersion & vbCr & myCopyright & vbCr & vbCr & _
"Please open an appointment first and re-run the script."
msgButtons = vbOKOnly + vbCritical
MsgBox msgPrompt, msgButtons
GoTo EndClean:
Case Is > 1
msgPrompt = myName & " - " & myVersion & vbCr & myCopyright & vbCr & vbCr & _
"Too many items were selected. Select exactly 1 appointment!"
msgButtons = vbOKOnly + vbCritical
MsgBox msgPrompt, msgButtons
GoTo EndClean:
End Select
' check if selected item it is an appointment
If objItem.Class <> 26 Then
msgPrompt = myName & " - " & myVersion & vbCr & myCopyright & vbCr & vbCr & _
"This script works only on appointments and meeting requests."
msgButtons = vbOKOnly + vbCritical
MsgBox msgPrompt, msgButtons
GoTo EndClean:
End If
Part 2:
' prepare the body for appended info
objItem.Body = objItem.Body + vbCr + vbCr + strDivider + vbCr + myName + " - " + myVersion + " " + myCopyright
objItem.Body = objItem.Body & vbCr & "collected following informations at " & Now() & vbCr & strDivider
objItem.Body = objItem.Body + vbCr + "Type " + vbTab + "Response" + vbTab + "Attendee" + vbCr + strDivider
Dim strMeetStatus As String
' get the attendee list and their responses
For x = 1 To objAttendees.Count
Select Case objAttendees(x).Type
Case olOptional '=2
strAttendeeType = "optional "
Case olOrganizer '=0
strAttendeeType = "organizer"
Case olRequired '=1
strAttendeeType = "required "
Case olResource '=3
strAttendeeType = "ressource"
Case Else
strAttendeeType = "unknown "
End Select
Select Case objAttendees(x).MeetingResponseStatus
Case olResponseAccepted '=3
strMeetStatus = "accepted"
Case olResponseDeclined '=4
strMeetStatus = "declined"
Case olResponseNone '=0
strMeetStatus = "none "
Case olResponseNotResponded '=5
strMeetStatus = "not responded"
Case olResponseOrganized '=1
strMeetStatus = "organized"
Case olResponseTentative '=2
strMeetStatus = "tentative"
End Select
If objItem.Organizer = objAttendees(x) Then
strAttendeeType = "organizer"
strMeetStatus = "organized"
End If
objItem.Body = objItem.Body + vbCr + strAttendeeType + vbTab + strMeetStatus + vbTab + objAttendees(x).Name
Next
objItem.Body = objItem.Body + vbCr + strDivider + vbCr
EndClean:
Set objApp = Nothing
Set objItem = Nothing
Set objSelection = Nothing
Set objAttendees = Nothing
End Sub
Some times ago my children helped me very well)))But serious some very important mails were corrupted and they found next tool-recover ost data,which recover all my data for free as far as I remember.Moreover tool could restore data from files with *.ost extension.
Oh my gosh so COOL!! Thanks!
Post a Comment
Subscribe to Post Comments [Atom]
Links to this post:
Create a Link
<< Home