Solved

Exporting or Backing up Calendar

Posted on 2006-06-22
11
882 Views
Last Modified: 2008-02-01
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
Comment
Question by:paulawest
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 97

Expert Comment

by:war1
ID: 16962968
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
 

Author Comment

by:paulawest
ID: 16963183
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
 
LVL 97

Expert Comment

by:war1
ID: 16963238
Paulawest,

I do not know of an addin.  Maybe someone else knows of a macro that will do what you want.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16963873
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
 

Author Comment

by:paulawest
ID: 16963995
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 76

Expert Comment

by:David Lee
ID: 16964887
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
 
LVL 76

Expert Comment

by:David Lee
ID: 16965443
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
 

Author Comment

by:paulawest
ID: 16965594
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
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 16967385
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
 

Expert Comment

by:greep
ID: 20175279
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
 
LVL 76

Expert Comment

by:David Lee
ID: 20182412
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Resolve DNS query failed errors for Exchange
Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now