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

Export Calendar to XML



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 20th 06, 07:38 AM posted to microsoft.public.outlook.program_vba
pmo
external usenet poster
 
Posts: 3
Default Export Calendar to XML

Hallo Leute.

Ich möchte mit folgendem Code alle CalendarItems in ein XML-File
schreiben. Das klappt eigentlich ganz gut. Aber bei einem Serientermin
wird nur einmal exportiert. Das heisst,
wenn ich einen neuen Serientermin erstelle, welcher beginnend am 24.Mai
2006 wöchentlich statt findet, bekomme ich im XML-File nur den Eintrag
vom 24.Mai 2006. Wie kann ich
die 'SubItems' dieser TeminSerie auch exportieren?

Hier mein Code:

Dim goNS As NameSpace
Dim goCal As MAPIFolder
Dim goCalItem As AppointmentItem

Dim goFSO As FileSystemObject
Dim gsXML As String
Dim giCounter As Integer

Sub Main()

Set goFSO = CreateObject("Scripting.FileSystemObject")
gsXML = Environ("USERPROFILE") & "\Desktop\Events.xml"
giCounter = 0

If goFSO.FileExists(gsXML) Then
If MsgBox("Die Datei '" & gsXML & "' existiert bereits." &
vbNewLine & _
"Soll Sie überschrieben werden?", vbQuestion +
vbYesNo, "Datei überschreiben?") = vbYes Then
goFSO.DeleteFile gsXML, True
goFSO.CreateTextFile gsXML, True
Else
Exit Sub
End If
Else
goFSO.CreateTextFile gsXML, True
End If

Open gsXML For Append As #10
Print #10, "?xml version=" & Chr(34) & "1.0" & Chr(34) & "?"
Print #10, "macromedia_resources xmlns:macromedia_resources="
& Chr(34) &
"http://www.macromedia.com/devnet/resources/macromedia_resources.dtd" &
Chr(34) & ""
Close #10

Set goNS = Outlook.Application.GetNamespace("MAPI")
Set goCal = goNS.GetDefaultFolder(olFolderCalendar)


For Each goCalItem In goCal.Items
If goCalItem.IsRecurring = True Then
'Item ist ein SerienTermin
Else
'Item ist kein SerienTermin
ExportToXML goCalItem.Subject, Format(goCalItem.Start,
"d.m.yyyy"), Format(goCalItem.Start, "hh:nn"), goCalItem.Body
End If
Next goCalItem


Open gsXML For Append As #11
Print #11, "/macromedia_resources"
Close #11

Set goFSO = Nothing
Set goNS = Nothing
Set goCal = Nothing
Set goCalItem = Nothing

MsgBox "Export abgeschlossen"

End Sub

Sub ExportToXML(lsSubject As String, lsDate As String, lsTime As
String, lsMemo As String)

Open gsXML For Append As #1
If giCounter = 0 Then
Print #1, vbTab & "resource type=" & Chr(34) & "Column" &
Chr(34) & ""
Else
Print #1, vbTab & "resource type=" & Chr(34) & "Article" &
Chr(34) & ""
End If

Print #1, vbTab & vbTab & "date" & Format(lsDate, "d.m.yyyy")
& "/date"
Print #1, vbTab & vbTab & "time" & Format(lsTime, "hh:nn") &
"/time"
Print #1, vbTab & vbTab & "title" & lsSubject & "/title"
Print #1, vbTab & vbTab & "desc" & lsMemo & "/desc"

Print #1, vbTab & "/resource"
Close #1

giCounter = giCounter + 1

End Sub

Ich bin euch für jede Hilfe dankbar.

Gruss pmo

Ads
  #2  
Old May 20th 06, 09:06 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Export Calendar to XML

Am 19 May 2006 22:38:35 -0700 schrieb pmo:

Before the loop please set the Item´s property IncludeRecurrences = True.

BTW: This is an English speaking group. You´d increase your chance for
answers dramatically by speaking English, too.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Hallo Leute.

Ich möchte mit folgendem Code alle CalendarItems in ein XML-File
schreiben. Das klappt eigentlich ganz gut. Aber bei einem Serientermin
wird nur einmal exportiert. Das heisst,
wenn ich einen neuen Serientermin erstelle, welcher beginnend am 24.Mai
2006 wöchentlich statt findet, bekomme ich im XML-File nur den Eintrag
vom 24.Mai 2006. Wie kann ich
die 'SubItems' dieser TeminSerie auch exportieren?

Hier mein Code:

Dim goNS As NameSpace
Dim goCal As MAPIFolder
Dim goCalItem As AppointmentItem

Dim goFSO As FileSystemObject
Dim gsXML As String
Dim giCounter As Integer

Sub Main()

Set goFSO = CreateObject("Scripting.FileSystemObject")
gsXML = Environ("USERPROFILE") & "\Desktop\Events.xml"
giCounter = 0

If goFSO.FileExists(gsXML) Then
If MsgBox("Die Datei '" & gsXML & "' existiert bereits." &
vbNewLine & _
"Soll Sie überschrieben werden?", vbQuestion +
vbYesNo, "Datei überschreiben?") = vbYes Then
goFSO.DeleteFile gsXML, True
goFSO.CreateTextFile gsXML, True
Else
Exit Sub
End If
Else
goFSO.CreateTextFile gsXML, True
End If

Open gsXML For Append As #10
Print #10, "?xml version=" & Chr(34) & "1.0" & Chr(34) & "?"
Print #10, "macromedia_resources xmlns:macromedia_resources="
& Chr(34) &
"http://www.macromedia.com/devnet/resources/macromedia_resources.dtd" &
Chr(34) & ""
Close #10

Set goNS = Outlook.Application.GetNamespace("MAPI")
Set goCal = goNS.GetDefaultFolder(olFolderCalendar)


For Each goCalItem In goCal.Items
If goCalItem.IsRecurring = True Then
'Item ist ein SerienTermin
Else
'Item ist kein SerienTermin
ExportToXML goCalItem.Subject, Format(goCalItem.Start,
"d.m.yyyy"), Format(goCalItem.Start, "hh:nn"), goCalItem.Body
End If
Next goCalItem


Open gsXML For Append As #11
Print #11, "/macromedia_resources"
Close #11

Set goFSO = Nothing
Set goNS = Nothing
Set goCal = Nothing
Set goCalItem = Nothing

MsgBox "Export abgeschlossen"

End Sub

Sub ExportToXML(lsSubject As String, lsDate As String, lsTime As
String, lsMemo As String)

Open gsXML For Append As #1
If giCounter = 0 Then
Print #1, vbTab & "resource type=" & Chr(34) & "Column" &
Chr(34) & ""
Else
Print #1, vbTab & "resource type=" & Chr(34) & "Article" &
Chr(34) & ""
End If

Print #1, vbTab & vbTab & "date" & Format(lsDate, "d.m.yyyy")
& "/date"
Print #1, vbTab & vbTab & "time" & Format(lsTime, "hh:nn") &
"/time"
Print #1, vbTab & vbTab & "title" & lsSubject & "/title"
Print #1, vbTab & vbTab & "desc" & lsMemo & "/desc"

Print #1, vbTab & "/resource"
Close #1

giCounter = giCounter + 1

End Sub

Ich bin euch für jede Hilfe dankbar.

Gruss pmo

  #3  
Old May 20th 06, 09:35 AM posted to microsoft.public.outlook.program_vba
pmo
external usenet poster
 
Posts: 3
Default Export Calendar to XML

Hi Michael.

Sorry, but my written English is very bad... so i think it is better
that i use German.

I have implemted the ItemsProperty, but i does still not work.

Here is my Code:

Set goCal = goNS.GetDefaultFolder(olFolderCalendar)
Set goCalItems = goCal.Items

goCalItems.IncludeRecurrences = True

For Each goCalItem In goCalItems
ExportToXML goCalItem.Subject, Format(goCalItem.Start,
"d.m.yyyy"), Format(goCalItem.Start, "hh:nn"), goCalItem.Body
Next goCalItem

Why ???

Best regards

pmo

  #4  
Old May 20th 06, 09:45 AM posted to microsoft.public.outlook.program_vba
pmo
external usenet poster
 
Posts: 3
Default Export Calendar to XML

I got it ;-)

I forgot to define the .sort Property.

Thanx for Your help.

Greez pmo

  #5  
Old May 21st 06, 01:34 PM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Export Calendar to XML

Am 20 May 2006 00:35:58 -0700 schrieb pmo:

As far as I can tell, your written English good. Anyway, if you rather like
to discuss in German then please try microsoft.public.de.outlook


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Hi Michael.

Sorry, but my written English is very bad... so i think it is better
that i use German.

I have implemted the ItemsProperty, but i does still not work.

Here is my Code:

Set goCal = goNS.GetDefaultFolder(olFolderCalendar)
Set goCalItems = goCal.Items

goCalItems.IncludeRecurrences = True

For Each goCalItem In goCalItems
ExportToXML goCalItem.Subject, Format(goCalItem.Start,
"d.m.yyyy"), Format(goCalItem.Start, "hh:nn"), goCalItem.Body
Next goCalItem

Why ???

Best regards

pmo

 




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
export calendar Outlook XP fitcajun Outlook - Calandaring 0 May 9th 06 04:34 PM
Xml Richard Outlook Express 1 May 1st 06 12:15 AM
Programming changes to XML properties Ray Jackson Outlook and VBA 1 February 7th 06 02:06 PM
How to export data from personal calendar to default calendar npharrison Outlook - Calandaring 11 February 1st 06 05:31 PM
How do I export the calendar data to a XML file? Satya Outlook - Calandaring 1 January 30th 06 07:18 AM


All times are GMT +1. The time now is 09:03 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.