Live-Forum - Die aktuellen Beiträge
Datum
Titel
16.10.2025 17:40:39
16.10.2025 17:25:38
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender

Forumthread: Outlooktermine aus Excel erstellen

Outlooktermine aus Excel erstellen
09.01.2024 15:18:57
Schwobeklaus
Hallo,

ich möchte Outlooktermine aus Excel erstellen und habe dazu fleissig ChatGPT bemüht. Ich verstehe das Skript, leider wird keine Termineinladung verschickt. Es kommt auch keine Fehlermeldung.
unter Extras -> Verweise habe ich die Microsoft Outlook 16.0 Object Library aktiviert.

Hat jemand eine Idee, warum das Skipt nicht funktioniert?

Sub CreateOutlookAppointments()

Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Dim olRecip As Outlook.Recipient
Dim olAttendees As Outlook.Recipients
Dim olOptionalAttendees As Outlook.Recipients
Dim olAttach As Outlook.Attachment
Dim i As Long

Set olApp = New Outlook.Application

'Get the active worksheet in Excel
Dim ws As Worksheet
Set ws = ActiveSheet

'Loop through the rows in the worksheet and create appointments
For i = 2 To ws.Cells(Rows.Count, "A").End(xlUp).Row

'Create a new appointment item
Set olAppt = olApp.CreateItem(olAppointmentItem)

'Set the appointment details
olAppt.Subject = ws.Cells(i, 1).Value
olAppt.Location = ws.Cells(i, 2).Value
olAppt.Start = ws.Cells(i, 3).Value
olAppt.Duration = ws.Cells(i, 4).Value
olAppt.ReminderSet = True
olAppt.ReminderMinutesBeforeStart = 15

'Add required attendees
Set olAttendees = olAppt.Recipients
For Each cell In Split(ws.Cells(i, 5).Value, ";")
Set olRecip = olAttendees.Add(cell)
olRecip.Type = olTo
Next

'Add optional attendees
Set olOptionalAttendees = olAppt.Recipients
For Each cell In Split(ws.Cells(i, 6).Value, ";")
Set olRecip = olOptionalAttendees.Add(cell)
olRecip.Type = olOptional
Next

'Add attachment to the appointment
If Len(ws.Cells(i, 7).Value) > 0 Then
Set olAttach = olAppt.Attachments.Add(ws.Cells(i, 7).Value)
End If

'Send the appointment
olAppt.Send

'Release the attachment object
If Not olAttach Is Nothing Then
Set olAttach = Nothing
End If

Next

'Release objects from memory
Set olOptionalAttendees = Nothing
Set olAttendees = Nothing
Set olRecip = Nothing
Set olAppt = Nothing
Set olApp = Nothing

End Sub

Anzeige

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Outlooktermine aus Excel erstellen
09.01.2024 15:56:53
Oberschlumpf
Hi,

ich könnt mir vorstellen, es könnte mehr Ideen geben, wenn du anstelle von nur Code zusätzlich auch eine Bsp-Datei zeigst mit genügend Bsp-Daten und dem Code in der Datei.

Ciao
Thorsten
AW: Outlooktermine aus Excel erstellen
09.01.2024 16:02:15
Schwobeklaus
Gute Idee. Habe die Datei hier hochgeladen:

https://www.herber.de/bbs/user/165983.xlsm

Anzeige
AW: Outlooktermine aus Excel erstellen
09.01.2024 17:13:10
Hardy R
Hallo Schwobeklaus,

habe damals was im I-net gefunden und konnte es für mich anpassen.

Vielleicht hilft es dir ja
https://www.herber.de/bbs/user/165986.xlsm

Gruß Hardy
AW: Outlooktermine aus Excel erstellen
10.01.2024 15:43:28
Schwobeklaus
Hallo Hardy,

danke für die Datei. Hat mir etwas weitergeholfen, allerdings werden dort nur Termine im eigenen Kalender eingetragen - ich möchte diese aber versenden.

Ich bin etwas weitergekommen insofern, dass ich in meinem Skript anstatt
.Send
einfach mal mit
.Display
geschaut habe, ob der Termin nach Outlook übertragen wird. Das funktioniert. Allerdings tauchen die Empfänger erst auf, wenn ich in Outlook auf "Teilnehmer einladen" klicke.

Userbild

Userbild

hier die Beispieldatei
https://www.herber.de/bbs/user/166007.xlsm
Anzeige
AW: Outlooktermine aus Excel erstellen
12.01.2024 09:09:45
Schwobeklaus
GELÖST:

Der Termin-Typ war falsch. Es muss
Meeting
anstatt
Appointment
sein.

Hier der Code, falls die Nachwelt mal nach so etwas sucht:



'Vorher: Extras -> Verweise -> "Microsoft Outlook Object Library" aktivieren

Sub CreateOutlookAppointments()
Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Dim olRecip As Outlook.Recipient
Dim olAttendees As Outlook.Recipients
Dim olOptionalAttendees As Outlook.Recipients
Dim olAttach As Outlook.Attachment
Dim i As Long

Set olApp = New Outlook.Application

'Get the active worksheet in Excel
Dim ws As Worksheet
Set ws = ActiveSheet

'Loop through the rows in the worksheet and create appointments
For i = 2 To ws.Cells(Rows.Count, "A").End(xlUp).Row

'Create a new appointment item
Set olAppt = olApp.CreateItem(olAppointmentItem)

'Set Type to "Meeting" (not Appointment)
olAppt.MeetingStatus = olMeeting

'Set the appointment details
olAppt.Subject = ws.Cells(i, 1).Value
olAppt.Location = ws.Cells(i, 2).Value
'olAppt.Start = ws.Cells(i, 3).Value 'DD.MM.YYYY HH:MM
olAppt.Start = ws.Cells(i, 3).Value & " " & ws.Cells(i, 4).Value 'DD.MM.YYYY & HH:MM
olAppt.Duration = ws.Cells(i, 5).Value 'M
olAppt.ReminderSet = True
olAppt.ReminderMinutesBeforeStart = 15

'Add required attendees
Set olAttendees = olAppt.Recipients
For Each cell In Split(ws.Cells(i, 6).Value, ";")
Set olRecip = olAttendees.Add(cell)
olRecip.Type = olTo
Next

'Add optional attendees
Set olOptionalAttendees = olAppt.Recipients
For Each cell In Split(ws.Cells(i, 7).Value, ";")
Set olRecip = olOptionalAttendees.Add(cell)
olRecip.Type = olOptional
Next

'Add attachment to the appointment
If Len(ws.Cells(i, 8).Value) > 0 Then
Set olAttach = olAppt.Attachments.Add(ws.Cells(i, 8).Value)
End If

'Send the appointment
'olAppt.Send

'Show appointment
olAppt.Display

'Release the attachment object
If Not olAttach Is Nothing Then
Set olAttach = Nothing
End If

Next

'Release objects from memory
Set olOptionalAttendees = Nothing
Set olAttendees = Nothing
Set olRecip = Nothing
Set olAppt = Nothing
Set olApp = Nothing

End Sub

Anzeige
;

Forumthreads zu verwandten Themen

Anzeige
Anzeige
Anzeige
Anzeige
Entdecke relevante Threads

Schau dir verwandte Threads basierend auf dem aktuellen Thema an

Alle relevanten Threads mit Inhaltsvorschau entdecken
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige