A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Extracting Public Calendar Information to Excel



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 19th 06, 07:09 PM posted to microsoft.public.outlook.program_vba
WD
external usenet poster
 
Posts: 6
Default Extracting Public Calendar Information to Excel

I have a VBA code in Excel that I use to extract calendar information from my
calendar to an Excel sheet. I would like to extract from a public calendar
instead. Is this possible? and if yes, what changes would I need to make to
the code below to do that. Any assistance would be helpful. Thanks


Private Sub GetMeetings_Click()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appts As Object
Dim appt As Object
Dim date1 As Date, date2 As Date
Dim i As Integer

Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderCalendar)
Set appts = olFolder.Items

date1 = InputBox("Starting Date: ", "Start Date")
date2 = InputBox("End Date: ", "End Date")

i = 2
For Each appt In appts
If appt.Start = date1 And appt.Start date2 Then
Sheets("rawdata").Cells(i, 2).Value = appt.ConversationTopic
Sheets("rawdata").Cells(i, 4).Value = Format(appt.Start, "short date")
Sheets("rawdata").Cells(i, 5).Value = Format(appt.Start, "medium
time")
Sheets("rawdata").Cells(i, 6).Value = Format(appt.End, "medium time")
Sheets("rawdata").Cells(i, 7).Value = appt.Location
Sheets("rawdata").Cells(i, 3).Value = appt.Organizer
Sheets("rawdata").Cells(i, 8).Value = appt.Body
Sheets("rawdata").Cells(i, 9).Value = appt.RequiredAttendees
Sheets("rawdata").Cells(i, 10).Value = appt.OptionalAttendees
i = i + 1
End If
Next appt

Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
End Sub

Ads
  #2  
Old April 19th 06, 07:21 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Extracting Public Calendar Information to Excel

You'd need to replace your GetDefaultFolder statement with a statement that returns the public folder. To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm and, especially for public folders, http://www.outlookcode.com/codedetail.aspx?id=1164
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"WD" wrote in message ...
I have a VBA code in Excel that I use to extract calendar information from my
calendar to an Excel sheet. I would like to extract from a public calendar
instead. Is this possible? and if yes, what changes would I need to make to
the code below to do that. Any assistance would be helpful. Thanks


Private Sub GetMeetings_Click()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appts As Object
Dim appt As Object
Dim date1 As Date, date2 As Date
Dim i As Integer

Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderCalendar)
Set appts = olFolder.Items

date1 = InputBox("Starting Date: ", "Start Date")
date2 = InputBox("End Date: ", "End Date")

i = 2
For Each appt In appts
If appt.Start = date1 And appt.Start date2 Then
Sheets("rawdata").Cells(i, 2).Value = appt.ConversationTopic
Sheets("rawdata").Cells(i, 4).Value = Format(appt.Start, "short date")
Sheets("rawdata").Cells(i, 5).Value = Format(appt.Start, "medium
time")
Sheets("rawdata").Cells(i, 6).Value = Format(appt.End, "medium time")
Sheets("rawdata").Cells(i, 7).Value = appt.Location
Sheets("rawdata").Cells(i, 3).Value = appt.Organizer
Sheets("rawdata").Cells(i, 8).Value = appt.Body
Sheets("rawdata").Cells(i, 9).Value = appt.RequiredAttendees
Sheets("rawdata").Cells(i, 10).Value = appt.OptionalAttendees
i = i + 1
End If
Next appt

Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
End Sub

  #3  
Old April 19th 06, 09:04 PM posted to microsoft.public.outlook.program_vba
WD
external usenet poster
 
Posts: 6
Default Extracting Public Calendar Information to Excel

Thanks Sue -

I looked on the website you provided (outlookcode.com) and went with a
getfolderbyname example because I wasn't sure of the path of the public
folder. I also had a sub-folder included in the folders that I was going to
be searching. Now I am adding an array to pull the strings together from the
multiple calendars that I have before writing them into different tabs in
Excel. thanks.

"Sue Mosher [MVP-Outlook]" wrote:

You'd need to replace your GetDefaultFolder statement with a statement that returns the public folder. To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm and, especially for public folders, http://www.outlookcode.com/codedetail.aspx?id=1164
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"WD" wrote in message ...
I have a VBA code in Excel that I use to extract calendar information from my
calendar to an Excel sheet. I would like to extract from a public calendar
instead. Is this possible? and if yes, what changes would I need to make to
the code below to do that. Any assistance would be helpful. Thanks


Private Sub GetMeetings_Click()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appts As Object
Dim appt As Object
Dim date1 As Date, date2 As Date
Dim i As Integer

Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderCalendar)
Set appts = olFolder.Items

date1 = InputBox("Starting Date: ", "Start Date")
date2 = InputBox("End Date: ", "End Date")

i = 2
For Each appt In appts
If appt.Start = date1 And appt.Start date2 Then
Sheets("rawdata").Cells(i, 2).Value = appt.ConversationTopic
Sheets("rawdata").Cells(i, 4).Value = Format(appt.Start, "short date")
Sheets("rawdata").Cells(i, 5).Value = Format(appt.Start, "medium
time")
Sheets("rawdata").Cells(i, 6).Value = Format(appt.End, "medium time")
Sheets("rawdata").Cells(i, 7).Value = appt.Location
Sheets("rawdata").Cells(i, 3).Value = appt.Organizer
Sheets("rawdata").Cells(i, 8).Value = appt.Body
Sheets("rawdata").Cells(i, 9).Value = appt.RequiredAttendees
Sheets("rawdata").Cells(i, 10).Value = appt.OptionalAttendees
i = i + 1
End If
Next appt

Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
End Sub


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
extracting mailitem.body text to Excel columns Junoon Outlook and VBA 3 April 20th 06 06:45 AM
How can I extract share calender information to excel sheet TILLYCHIPS Outlook - Calandaring 1 April 17th 06 04:37 PM
how can I download contact information to an excel spreadsheet Larry H Outlook - Using Contacts 1 March 17th 06 05:41 PM
Import from Excel User specified Contact Information ut Outlook - General Queries 2 February 2nd 06 04:38 PM
export a public contact folder to excel? mjb Outlook - Using Contacts 1 January 20th 06 06:44 AM


All times are GMT +1. The time now is 08:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.