• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 972
  • Last Modified:

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  ;>)
0
paulawest
Asked:
paulawest
  • 5
  • 3
  • 2
  • +1
1 Solution
 
war1Commented:
Greetings, paulawest !

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!
0
 
paulawestAuthor Commented:
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.
0
 
war1Commented:
Paulawest,

I do not know of an addin.  Maybe someone else knows of a macro that will do what you want.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
David LeeCommented:
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!
0
 
paulawestAuthor Commented:
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!
0
 
David LeeCommented:
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.  
0
 
David LeeCommented:
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(olFolderCalendar).Items
        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
0
 
paulawestAuthor Commented:
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!
0
 
David LeeCommented:
If they know Outlook's object model, then yes.  To save you a little time, here's the code for firing this each time Outlook exits.  This code has to go in the module ThisOutlookSession.

Private Sub Application_Quit()
    ExportCalendar
End Sub


You're welcome.  Glad I could help out.
0
 
greepCommented:
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.
0
 
David LeeCommented:
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.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now