I'm trying to write a small Outlook VBA Script which reads my Sharepoint Calendar Entries and then adds another One to my personal Calendar with an Offest of 4 hours on the same day. So far I got the following which successfully creates a new Entry but my For Each Loop doesnt seem to work as it always jumps back to the main Function when I try to create a new Entry with the Date and Time read from the Variable "newStart":
Thats my Code so far:
Public newStart As String
Sub ReadEntries()
Dim oApp As Outlook.Application
On Error Resume Next
' check if Outlook is running
Set oApp = GetObject("Outlook.Application")
If Err <> 0 Then
'if not running, start it
Set oApp = CreateObject("Outlook.Application")
End If
Set olApp = New Outlook.Application
Set olFldr = olApp.GetNamespace("MAPI").Folders("Other Calendars").Folders("FOLDERNAME")
For Each Items In olFldr
If olFldr.Items.Subject = "Given Entry Title" Then
newStart = olFldr.Items.Start
CreateStandby
End If
Next
Set oObject = Nothing
Set oApp = Nothing
End Sub
Sub CreateStandby()
Dim standbyEntry As Object
Set standbyEntry = Application.CreateItem(olAppointmentItem)
standbyEntry.Subject = "New Entry Title"
standbyEntry.Start = newStart
standbyEntry.Duration = 240
standbyEntry.BusyStatus = olOutOfOffice
standbyEntry.Send
standbyEntry.Save
End Sub
Any Help will be appreciated as I am just a beginner who wants to make his Life easier.
Best Regards!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…