G
Guest
Hello,
I have written an Function:
Public Function MakeAppointment(strOutlookFolderID As String, strSubject As
String, datDatum As Date, strLocation As String, strBody As String, bolAllDay
As Boolean, Optional strvon As String, Optional strbis As String, Optional
strOutlook As String) As String
5 On Error GoTo Handler
Dim olfolder As Outlook.MAPIFolder
Dim olApp As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim olns As Outlook.NameSpace
10 Set olApp = CreateObject("Outlook.Application")
15 Set olfolder =
olApp.GetNamespace("MAPI").GetFolderFromID(strOutlookFolderID)
20 If Nz(strOutlook) = "" Then
25 Set objAppt = olfolder.Items.Add
30 Else
35 Set olns = olApp.GetNamespace("MAPI")
40 Set objAppt = olns.GetItemFromID(strOutlook, olfolder.StoreID)
45 End If
50 With objAppt
55 .Subject = strSubject
60 If Nz(Trim(strLocation)) <> "" Then
65 .Location = strLocation
70 End If
75 If bolAllDay = False Then
80 .start = CDate(datDatum & " " & strvon & ":00")
85 .End = CDate(datDatum & " " & strbis & ":00")
90 .AllDayEvent = False
95 Else
100 .start = datDatum
105 .AllDayEvent = True
110 End If
115 .ReminderSet = False
120 .Body = strBody
'.Importance = olImportanceHigh
125 .Save
130 MakeAppointment = .EntryID
135 End With
140 Set objAppt = Nothing
145 Set olApp = Nothing
150 Set olfolder = Nothing
155 Set olns = Nothing
160 Exit Function
Handler:
Msgbox Err.number & "|" & Err.Description
End Function
But sometimes and mainly when Outlook not started, I get en Error in line
15? Why?
I hope anyone can help me.
Thank you.
Marius
I have written an Function:
Public Function MakeAppointment(strOutlookFolderID As String, strSubject As
String, datDatum As Date, strLocation As String, strBody As String, bolAllDay
As Boolean, Optional strvon As String, Optional strbis As String, Optional
strOutlook As String) As String
5 On Error GoTo Handler
Dim olfolder As Outlook.MAPIFolder
Dim olApp As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim olns As Outlook.NameSpace
10 Set olApp = CreateObject("Outlook.Application")
15 Set olfolder =
olApp.GetNamespace("MAPI").GetFolderFromID(strOutlookFolderID)
20 If Nz(strOutlook) = "" Then
25 Set objAppt = olfolder.Items.Add
30 Else
35 Set olns = olApp.GetNamespace("MAPI")
40 Set objAppt = olns.GetItemFromID(strOutlook, olfolder.StoreID)
45 End If
50 With objAppt
55 .Subject = strSubject
60 If Nz(Trim(strLocation)) <> "" Then
65 .Location = strLocation
70 End If
75 If bolAllDay = False Then
80 .start = CDate(datDatum & " " & strvon & ":00")
85 .End = CDate(datDatum & " " & strbis & ":00")
90 .AllDayEvent = False
95 Else
100 .start = datDatum
105 .AllDayEvent = True
110 End If
115 .ReminderSet = False
120 .Body = strBody
'.Importance = olImportanceHigh
125 .Save
130 MakeAppointment = .EntryID
135 End With
140 Set objAppt = Nothing
145 Set olApp = Nothing
150 Set olfolder = Nothing
155 Set olns = Nothing
160 Exit Function
Handler:
Msgbox Err.number & "|" & Err.Description
End Function
But sometimes and mainly when Outlook not started, I get en Error in line
15? Why?
I hope anyone can help me.
Thank you.
Marius