Re: VBA - Connect excel with Outlook problem?!
As of now the subs are without the 'apponday' part. But that shouldnt matter. It worked fine before i split it up...I cant quite find the error... So ill just post the first sub of three (its long but its basically the same over and over again just a new month..:
Public Function CheckAppointmentExists(argCheckDate As Date, argCheckSubject As String) As Boolean
Dim oApp As Outlook.Application
Dim oNameSpace As Outlook.Namespace
Dim oApptItem As Outlook.AppointmentItem
Dim oFolder As Outlook.MAPIFolder
Dim oMeetingoApptItem As Outlook.MeetingItem
Dim oObject As Object
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 oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderCalendar)
CheckAppointmentExists = False
For Each oObject In oFolder.Items
If oObject.Class = olAppointment Then
Set oApptItem = oObject
If oApptItem.Start = argCheckDate Then
CheckAppointmentExists = True
End If
End If
Next oObject
Set oApp = Nothing
Set oNameSpace = Nothing
Set oApptItem = Nothing
Set oFolder = Nothing
Set oObject = Nothing
End Function
Sub MainMacro()
Call OpdaterOutlook
Call OpdaterOutlook1
Call OpdaterOutlook2
End Sub
Sub OpdaterOutlook()
Dim obJ0L As Object
Set obJ0L = CreateObject("Outlook.Application")
Set obJ0L = New Outlook.Application
Dim ONS As Outlook.Namespace
Set ONS = obJ0L.GetNamespace("MAPI")
Dim CAL_FOL As Outlook.Folder
Set CAL_FOL = ONS.GetDefaultFolder(olFolderCalendar).Folders("Excel")
Dim myapt As Outlook.AppointmentItem
Dim dCell As Range
'Maj måned starter her
For Each dCell In Range("D10:D40")
If dCell.Value = "dag" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:00"), "Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "overtid dag udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "overtid dag afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "aften" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:00"), "Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "overtid aft udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "overtid aft afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "nat" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:00"), "Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "overtid nat udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "overtid nat afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "support" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Support") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Support"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "kursus" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:02"), "Kursus") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Kursus"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "fri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:01"), "Fri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Fri"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "ferie" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:02"), "Ferie") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Ferie"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D10:D40")
If dCell.Value = "feriefri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:03"), "Feriefri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Feriefri"
.Save
End With
End If
End If
Next dCell
'Juni måned starter her
For Each dCell In Range("L10:L40")
If dCell.Value = "dag" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:00"), "Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "overtid dag udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "overtid dag afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "aften" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:00"), "Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "overtid aft udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "overtid aft afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "nat" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:00"), "Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "overtid nat udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "overtid nat afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "support" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Support") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Support"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "kursus" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:02"), "Kursus") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Kursus"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "fri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:01"), "Fri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Fri"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "ferie" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:02"), "Ferie") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Ferie"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("L10:L40")
If dCell.Value = "feriefri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:03"), "Feriefri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Feriefri"
.Save
End With
End If
End If
Next dCell
'Juli måned starter her
For Each dCell In Range("T10:T40")
If dCell.Value = "dag" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:00"), "Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "overtid dag udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "overtid dag afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "aften" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:00"), "Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "overtid aft udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "overtid aft afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "nat" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:00"), "Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "overtid nat udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "overtid nat afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "support" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Support") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Support"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "kursus" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:02"), "Kursus") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Kursus"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "fri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:01"), "Fri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Fri"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "ferie" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:02"), "Ferie") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Ferie"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("T10:T40")
If dCell.Value = "feriefri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:03"), "Feriefri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Feriefri"
.Save
End With
End If
End If
Next dCell
'August starter her
For Each dCell In Range("D49:D79")
If dCell.Value = "dag" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:00"), "Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "overtid dag udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "overtid dag afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Overtid Dagsvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Overtid Dagsvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "aften" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:00"), "Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "overtid aft udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "overtid aft afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("14:45:01"), "Overtid Aftenvagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("14:45:00")
.End = dCell.Offset(0, -2) + TimeValue("23:00:00")
.Subject = "Overtid Aftenvagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "nat" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:00"), "Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "overtid nat udb" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "overtid nat afs" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("22:45:01"), "Overtid Nattevagt") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("22:45:00")
.End = dCell.Offset(1, -2) + TimeValue("07:00:00")
.Subject = "Overtid Nattevagt"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "support" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:01"), "Support") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Support"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "kursus" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("06:45:02"), "Kursus") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("06:45:00")
.End = dCell.Offset(0, -2) + TimeValue("15:00:00")
.Subject = "Kursus"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "fri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:01"), "Fri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Fri"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "ferie" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:02"), "Ferie") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Ferie"
.Save
End With
End If
End If
Next dCell
For Each dCell In Range("D49:D79")
If dCell.Value = "feriefri" Then
If CheckAppointmentExists(dCell.Offset(0, -2) + TimeValue("00:00:03"), "Feriefri") = True Then
Else
Set myapt = CAL_FOL.Items.Add(olAppointmentItem)
With myapt
.Start = dCell.Offset(0, -2) + TimeValue("00:00:00")
.End = dCell.Offset(0, -2) + TimeValue("00:00:00")
.Subject = "Feriefri"
.Save
End With
End If
End If
Next dCell
End Sub