paulawest
asked on
Exporting or Backing up Calendar
I'm looking for a macro or add-in to automate the export (backup) of Calendar. Our lead chemist keeps retest dates in Calendar and some are 3 - 6 months out and others 24 - 36 months. I suggested the MS Outlook Backup utility but he wants to secure only the Calendar data and the utility backs up the entire Personal Folder. I also suggested creating a seperate folder and just keeping the Calendar data current, but he's convinced me that's too complicated for a chemist ;>)
ASKER
Thanks War1, I had seen that during my initial research so what I was wondering was if the same thing could be accomplished via macro or add-in, (maybe to fire when closing Outlook) and whether someone had written such.
Paulawest,
I do not know of an addin. Maybe someone else knows of a macro that will do what you want.
I do not know of an addin. Maybe someone else knows of a macro that will do what you want.
Hi paulawest,
Such a macro is pretty simple so long as we're talking about copying and not synchronizing. If it's a straight copy, then let me know and I'll post the code.
Cheers!
Such a macro is pretty simple so long as we're talking about copying and not synchronizing. If it's a straight copy, then let me know and I'll post the code.
Cheers!
ASKER
Exactly! The goal, of course, is to be able to recover the Calendar data in the event of PC loss or migration. I am curious though about copy vs. export to file such as referenced above. Regardless, any code assist is greatly appreciated!
Ok. I'll get the code posted shortly. There is no difference between copy and export if you're considering the final product: a copy of the folder. There's a big difference though in the steps required. War1 listed the steps for exporting above. Using a code based solution we can those 13 steps down significantly, perhaps even to a single button click.
Here's the code for doing this. Follow these instructions to set the code up and use it.
1. Open Outlook.
2. Click Tools->Macro->Visual Basic Editor.
3. If it's not already expanded, expand Modules and click on Module1.
4. Copy the code I posted and paste it into the right-hand pane of the Visual Basic Editor.
5. Edit the code. I placed comments where things need to or can be changed.
6. Click the diskette icon to save the change.
7. Exit the Visual Basic Editor.
8. Click Tools->Macro->Security.
9. Change the Security Level to Medium.
10. Run the code. It will prompt the user for the name of a PST file to back the calendar up to. If not file name is entered, then nothing is done. If a file name is entered, then the code will create a PST file, copy the contents of the calendar to the PST file, and close the PST file. I wrote and tested this using Outlook 2003.
Sub ExportCalendar()
Dim olkNS As Outlook.NameSpace, _
olkSourceCalendar As Outlook.Items, _
olkExportCalendar As Outlook.MAPIFolder, _
olkSourceItem As Outlook.AppointmentItem, _
olkExportItem As Outlook.AppointmentItem, _
olkTempFolder As Outlook.MAPIFolder, _
strPSTFileName As String, _
strMacroName As String
strMacroName = "ExportCalendar"
'Change the default path and file name on the following line
strPSTFileName = InputBox("Enter the file path and name of the PST file to export the calendar to.", strMacroName, "C:\eeTesting\Calendar Backup.pst")
If strPSTFileName <> "" Then
Set olkNS = Application.GetNamespace(" MAPI")
olkNS.AddStore strPSTFileName
Set olkTempFolder = olkNS.Folders.GetLast
'Change the PST file's display name on the following line if desired
olkTempFolder.Name = "Calendar Backup"
'Change the name of the folder in the PST file if desired
Set olkExportCalendar = olkTempFolder.Folders.Add( "Calendar" , olFolderCalendar)
Set olkSourceCalendar = Session.GetDefaultFolder(o lFolderCal endar).Ite ms
For Each olkSourceItem In olkSourceCalendar
Set olkExportItem = olkSourceItem.Copy
olkExportItem.Move olkExportCalendar
Next
olkNS.RemoveStore olkTempFolder
End If
Set olkTempFolder = Nothing
Set olkExportItem = Nothing
Set olkSourceItem = Nothing
Set olkExportCalendar = Nothing
Set olkSourceCalendar = Nothing
Set olkNS = Nothing
MsgBox "Export complete!", vbInformation + vbOKOnly, strMacroName
End Sub
1. Open Outlook.
2. Click Tools->Macro->Visual Basic Editor.
3. If it's not already expanded, expand Modules and click on Module1.
4. Copy the code I posted and paste it into the right-hand pane of the Visual Basic Editor.
5. Edit the code. I placed comments where things need to or can be changed.
6. Click the diskette icon to save the change.
7. Exit the Visual Basic Editor.
8. Click Tools->Macro->Security.
9. Change the Security Level to Medium.
10. Run the code. It will prompt the user for the name of a PST file to back the calendar up to. If not file name is entered, then nothing is done. If a file name is entered, then the code will create a PST file, copy the contents of the calendar to the PST file, and close the PST file. I wrote and tested this using Outlook 2003.
Sub ExportCalendar()
Dim olkNS As Outlook.NameSpace, _
olkSourceCalendar As Outlook.Items, _
olkExportCalendar As Outlook.MAPIFolder, _
olkSourceItem As Outlook.AppointmentItem, _
olkExportItem As Outlook.AppointmentItem, _
olkTempFolder As Outlook.MAPIFolder, _
strPSTFileName As String, _
strMacroName As String
strMacroName = "ExportCalendar"
'Change the default path and file name on the following line
strPSTFileName = InputBox("Enter the file path and name of the PST file to export the calendar to.", strMacroName, "C:\eeTesting\Calendar Backup.pst")
If strPSTFileName <> "" Then
Set olkNS = Application.GetNamespace("
olkNS.AddStore strPSTFileName
Set olkTempFolder = olkNS.Folders.GetLast
'Change the PST file's display name on the following line if desired
olkTempFolder.Name = "Calendar Backup"
'Change the name of the folder in the PST file if desired
Set olkExportCalendar = olkTempFolder.Folders.Add(
Set olkSourceCalendar = Session.GetDefaultFolder(o
For Each olkSourceItem In olkSourceCalendar
Set olkExportItem = olkSourceItem.Copy
olkExportItem.Move olkExportCalendar
Next
olkNS.RemoveStore olkTempFolder
End If
Set olkTempFolder = Nothing
Set olkExportItem = Nothing
Set olkSourceItem = Nothing
Set olkExportCalendar = Nothing
Set olkSourceCalendar = Nothing
Set olkNS = Nothing
MsgBox "Export complete!", vbInformation + vbOKOnly, strMacroName
End Sub
ASKER
Excellent!!
As far as what fires this, can an average VB coder add the code to fire this when Outlook closes or some other event? I can't thank you enough for the help!
As far as what fires this, can an average VB coder add the code to fire this when Outlook closes or some other event? I can't thank you enough for the help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello,
I would like to know if it is possible to modify this macro, so that the calendar is exported and saved as a .htm file (for only 1 month - start date would be the current date) for use on the web?
Many thanks.
I would like to know if it is possible to modify this macro, so that the calendar is exported and saved as a .htm file (for only 1 month - start date would be the current date) for use on the web?
Many thanks.
Hi, greep.
Probably, but it'd require a lot of work. There is no command in Outlook for exporting a calendar to HTML like the "Save as Web Page" menu selection. You'd have to script the whole thing from scratch. It's doable, but it'll require a good bit of scripting beyond what I posted here.
Probably, but it'd require a lot of work. There is no command in Outlook for exporting a calendar to HTML like the "Save as Web Page" menu selection. You'd have to script the whole thing from scratch. It's doable, but it'll require a good bit of scripting beyond what I posted here.
Here is how to export or backup Outlook Calendar
http://technology.iusm.iu.edu/TimeZoneDoc/CalendarBackup.pdf
1. Open OUTLOOK
2. Select “Calendar”
a. Choose from selection at lower left. Or, from the GO drop down menu
3. Click on the FILE drop down menu. . .
Then, Click on “Import and Export . . .”
(if you don’t’ see the “Import and Export…”, move the mouse pointer to the down arrows
to expand the drop down list.)
4. Select “Export to a file”
5. Click NEXT
6. Select “Personal Folder File (.pst)”
7. Click NEXT
8. Click on “CALENDAR” so it is highlighted
9. Click on the box marked “Include Subfolders” so the check mark appears.
10. Click NEXT
11. Under “Save Export file as . . .” Type “P:\calbackup.pst” (without the quotation marks)
12. Click Finish
13. Click OK
Best wishes!