PC Review


Reply
Thread Tools Rate Thread

Copying calender entries via code

 
 
John
Guest
Posts: n/a
 
      13th Jun 2005
Hi

Is there a way to copy entries from a calendar in the public folders to the
standard calendar via code ? A code example would be highly appreciated. If
this code can run under a timer then that would be even great.

Many Thanks

Regards


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      14th Jun 2005
Try this macro, which will copy all of the selected items in the active
Calendar to the default Calendar:

Sub CopyAppointmentItem()
Dim objNS As Outlook.NameSpace
Dim objAppt As Outlook.AppointmentItem
Dim objCopiedAppt As Outlook.AppointmentItem

If ActiveExplorer.Selection.Count = 0 Then Exit Sub

Set objNS = Application.GetNamespace("MAPI")
For Each objAppt In ActiveExplorer.Selection
Set objCopiedAppt = objAppt.Copy
objCopiedAppt.Move objNS.GetDefaultFolder(olFolderCalendar)
Next

Set objAppt = Nothing
Set objCopiedAppt = Nothing
Set objNS = Nothing
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


"John" wrote:

> Hi
>
> Is there a way to copy entries from a calendar in the public folders to the
> standard calendar via code ? A code example would be highly appreciated. If
> this code can run under a timer then that would be even great.
>
> Many Thanks
>
> Regards
>
>
>

 
Reply With Quote
 
John
Guest
Posts: n/a
 
      15th Jun 2005
Thanks for that. Any way to use "my calendar" under the public folders as
the source instead of the current calendar?

Thanks

Regards

"Eric Legault [MVP - Outlook]" <(E-Mail Removed)> wrote in
message news:CC6AFAF5-7DB8-4430-88C3-(E-Mail Removed)...
> Try this macro, which will copy all of the selected items in the active
> Calendar to the default Calendar:
>
> Sub CopyAppointmentItem()
> Dim objNS As Outlook.NameSpace
> Dim objAppt As Outlook.AppointmentItem
> Dim objCopiedAppt As Outlook.AppointmentItem
>
> If ActiveExplorer.Selection.Count = 0 Then Exit Sub
>
> Set objNS = Application.GetNamespace("MAPI")
> For Each objAppt In ActiveExplorer.Selection
> Set objCopiedAppt = objAppt.Copy
> objCopiedAppt.Move objNS.GetDefaultFolder(olFolderCalendar)
> Next
>
> Set objAppt = Nothing
> Set objCopiedAppt = Nothing
> Set objNS = Nothing
> End Sub
>
> --
> Eric Legault - B.A, MCP, MCSD, Outlook MVP
> Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
> Job: http://www.imaginets.com
> Blog: http://blogs.officezealot.com/legault/
>
>
> "John" wrote:
>
>> Hi
>>
>> Is there a way to copy entries from a calendar in the public folders to
>> the
>> standard calendar via code ? A code example would be highly appreciated.
>> If
>> this code can run under a timer then that would be even great.
>>
>> Many Thanks
>>
>> Regards
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      15th Jun 2005
You can obtain the handle to a folder (other than the active one using
ActiveExplorer.CurrentFolder) by using the NameSpace.GetFolderFromID method
if you know the unique ID of the folder in question.

Otherwise, you can pass the folder path (\\Public Folders\All Public
Folders\My Calendar) as an argument to the function below to obtain a
MAPIFolder object to use in the macro I gave you:

Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
On Error Resume Next
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = m_olApp.ActiveExplorer.CurrentFolder
End If
While strPath <> ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = m_olApp.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


"John" wrote:

> Thanks for that. Any way to use "my calendar" under the public folders as
> the source instead of the current calendar?
>
> Thanks
>
> Regards
>
> "Eric Legault [MVP - Outlook]" <(E-Mail Removed)> wrote in
> message news:CC6AFAF5-7DB8-4430-88C3-(E-Mail Removed)...
> > Try this macro, which will copy all of the selected items in the active
> > Calendar to the default Calendar:
> >
> > Sub CopyAppointmentItem()
> > Dim objNS As Outlook.NameSpace
> > Dim objAppt As Outlook.AppointmentItem
> > Dim objCopiedAppt As Outlook.AppointmentItem
> >
> > If ActiveExplorer.Selection.Count = 0 Then Exit Sub
> >
> > Set objNS = Application.GetNamespace("MAPI")
> > For Each objAppt In ActiveExplorer.Selection
> > Set objCopiedAppt = objAppt.Copy
> > objCopiedAppt.Move objNS.GetDefaultFolder(olFolderCalendar)
> > Next
> >
> > Set objAppt = Nothing
> > Set objCopiedAppt = Nothing
> > Set objNS = Nothing
> > End Sub
> >
> > --
> > Eric Legault - B.A, MCP, MCSD, Outlook MVP
> > Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
> > Job: http://www.imaginets.com
> > Blog: http://blogs.officezealot.com/legault/
> >
> >
> > "John" wrote:
> >
> >> Hi
> >>
> >> Is there a way to copy entries from a calendar in the public folders to
> >> the
> >> standard calendar via code ? A code example would be highly appreciated.
> >> If
> >> this code can run under a timer then that would be even great.
> >>
> >> Many Thanks
> >>
> >> Regards
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calender entries Dendeeman Microsoft Outlook Calendar 1 18th Nov 2009 08:07 PM
Copying calender entries via code John Microsoft Outlook Calendar 3 15th Jun 2005 03:36 PM
Copying calender entries via code John Microsoft Outlook 3 15th Jun 2005 03:36 PM
Copying calender entries via code John Microsoft Outlook Discussion 3 15th Jun 2005 03:36 PM
Calender Entries Sanjay Puri Microsoft Outlook Calendar 1 17th Jan 2004 04:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:44 AM.