Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1956to1960
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

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

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 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
Anzeige
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

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige