2016-08-10 3 views
0

Ich habe an einem Projekt gearbeitet, um Mitarbeiter Zeitpläne in einen freigegebenen oder globalen Kalender zu verschieben, auf den die Manager zugreifen können, um zu sehen, wer es außerhalb des Büros in jeder Woche gibt.Termine in einen nicht standardmäßigen Outlook-Kalender von Excel laden

Ich habe Probleme beim Speichern der Termine in den freigegebenen oder globalen Kalender. Es speichert in meinem Standardkalender. Ich habe ein paar verschiedene Ansätze ausprobiert. Dies ist der aktuelle Ansatz:

Sub Create_Outlook_2() 
' Create the Outlook session 

Dim oApp As Object 
Dim oNameSpace As Namespace 
Dim oFolder As Object 
Dim myApt As AppointmentItem 


Set oApp = New Outlook.Application 
Set oNameSpace = oApp.GetNamespace("MAPI") 
Set oFolder = oNameSpace.GetFolderFromID("000000007CF129E6C6BAA74F9B2AB399FABB280E01006EC36FFC70429B4EAE1875321A4609670078C4FA00320000").Items.Add(olAppointmentItem) 



With oFolder 
    ' Set myOutlook = CreateObject("Outlook.Application") 
' ' Set data collection to take from "Leave Table" sheet 
    Dim wsSrc As Worksheet 
    Set wsSrc = Sheets("Leave Table") 
    ' Start looping at row 3 (first two rows are for readability) 
    r = 3 
    ' Do/while set condition 
    Do Until Trim(wsSrc.Cells(r, 1).Value) = "" 
     ' Create event item 
     Set myApt = oApp.CreateItem(1) 
     ' Set the event properties 
     ' Set Subject line of event 
    With myApt 
     .Subject = "Time Off " & wsSrc.Cells(r, 1).Value & " " & wsSrc.Cells(r, 2).Value 
     ' Set start time 
     .Start = DateValue(wsSrc.Cells(r, 3)) + wsSrc.Cells(r, 8).Value 
     ' Set end time 
     .End = DateValue(wsSrc.Cells(r, 3)) + wsSrc.Cells(r, 9).Value 
     ' Turn reminders off 
     .ReminderSet = False 
     ' Set busy status to free 
     .BusyStatus = 0 
     ' Have the body of the event read as the decription from the leave form in Viewpoint 
     .Body = wsSrc.Cells(r, 4).Value 
     ' Save event in owners calendar 
     .Save 

     End With 
     ' Move to next row 
     r = r + 1 
     ' Repeat do/while loop until condition is no longer valid 
    Loop 

End With 
End Sub 

Es wird immer noch in den Standardkalender gespeichert.

Antwort

0

Ich fand es heraus !!!

Dieser Code funktioniert:

Sub Create_Outlook_2() 

    Dim oApp As Object 
    Dim oNameSpace As Namespace 
    Dim oFolder As Object 
    Dim wsSrc As Worksheet 
    Set wsSrc = Sheets("Leave Table") 
    ' Start looping at row 3 (first two rows are for readability) 
    r = 3 
    ' Do/while set condition 
    Do Until Trim(wsSrc.Cells(r, 1).Value) = "" 

    ' Create the Outlook session 
    Set oApp = New Outlook.Application 
    ' Set the namespace 
    Set oNameSpace = oApp.GetNamespace("MAPI") 
    ' Set the folder the appointment will be created in. 
    Set oFolder = oNameSpace.GetFolderFromID("Folder ID Number").Items.Add(olAppointmentItem) 

    ' Set with block for the appointment configuration loop 
    With oFolder 
     ' Set Subject line of event 
     .Subject = wsSrc.Cells(r, 1).Value & " " & wsSrc.Cells(r, 2).Value 
     ' Set start time 
     .Start = DateValue(wsSrc.Cells(r, 3)) + wsSrc.Cells(r, 8).Value 
     ' Set end time 
     .End = DateValue(wsSrc.Cells(r, 3)) + wsSrc.Cells(r, 9).Value 
     ' Turn reminders off 
     .ReminderSet = False 
     ' Set busy status to free 
     .BusyStatus = 0 
     ' Have the body of the event read as the decription from the leave form in Viewpoint 
     .Body = wsSrc.Cells(r, 4).Value 
     ' Save event in owners calendar 
     .Save 
     ' End with block 
     End With 
     ' Move to next row 
     r = r + 1 
     ' Repeat do/while loop until condition is no longer valid 
    Loop 

End Sub 

Um Ihre Ordner ID # zu erhalten:
Mit dem Kalender, den Sie erstellen möchten Termine in ausgewählten (öffnen Sie es in einem neuen Fenster für eine gute Maßnahme), drücken Sie F11 zu bringen Outlook-Makros und führen Sie den folgenden Code unter "Dieseoutlooksitzung":

Private Sub GetOutlookFolderID() 
    'Determines the Folder ID of Folder 
    Dim olfolder As Outlook.MAPIFolder 
    Dim olapp As Outlook.Application 
    Set olapp = CreateObject("Outlook.Application") 
    Set olfolder = olapp.GetNamespace("MAPI").PickFolder 
    olfolder.Display 
    MsgBox (olfolder.EntryID) 
    Set olfolder = Nothing 
    Set olapp = Nothing 
End Sub 

THE EXCEL SPREADSHEET I AM USING
- mit gefälschten Namen

Ich habe so viele Artikel und Themen heute zu diesem Thema gelesen und keiner von ihnen hat funktioniert. Ich hoffe, mein Leiden hilft einem anderen armen Praktikanten da draußen!

Besonderer Dank an alle, die diese Seite großartig machen! Nach drei Tagen, in denen ich mir selbst beigebracht habe, wie man grundlegende VBA und SQL macht, schätze ich diese Seite und all die Leute, die dazu beitragen, sehr.

Viel Glück da draußen!

0

Wenn Sie einen Termin in Outlook mit Excel erstellen möchten, führen Sie das folgende Skript aus.

Private Sub Add_Appointments_To_Outlook_Calendar() 

    'Include Microsoft Outlook nn.nn Object Library from Tools -> References 
    Dim oAppt As AppointmentItem 
    Dim Remind_Time As Double 

    i = 2 
    Subj = ThisWorkbook.Sheets(1).Cells(i, 1) 

    'Loop through entire list of Reminders to be added 
    While Subj <> "" 
     Set oAppt = Outlook.Application.CreateItem(olAppointmentItem) 

     oAppt.Subject = Subj 
     oAppt.Location = ThisWorkbook.Sheets(1).Cells(i, 2) 
     oAppt.Start = ThisWorkbook.Sheets(1).Cells(i, 3) 
     Remind_Time = ThisWorkbook.Sheets(1).Cells(i, 4) * 1 * 60 
     oAppt.ReminderMinutesBeforeStart = Remind_Time 
     oAppt.AllDayEvent = True 
     oAppt.Save 

     i = i + 1 
     Subj = ThisWorkbook.Sheets(1).Cells(i, 1) 
    Wend 
    MsgBox "Reminder(s) Added To Outlook Calendar" 

End Sub 

'Der Code stammt aus diesem Link: http://officetricks.com/add-appointment-to-outlook-calendar-through-excel-macro-vba/

Das Skript wird von Excel ausgeführt, und als solche müssen Sie einen Verweis auf Outlook einstellen, bevor Sie den Code ausführen. Beachten Sie außerdem, dass das Arbeitsblatt ordnungsgemäß eingerichtet sein muss, damit das Skript ausgeführt werden kann. Es sollte ungefähr so ​​aussehen. Alles wird von Excel in Outlook gelesen.

enter image description here

0

Es gibt eine weitere Möglichkeit, auf den Ordner zuzugreifen, anstatt die ID des Erhaltens:

Set oFolder = oNameSpace.Folders.Item("account address").Folders.Item("Calendar").Items.Add(olAppointmentItem) 

Wo „Konto-Adresse“ ist die E-Mail-Adresse des Kontos

Zusätzlich I‘ Ich arbeite mit mehreren Outlook.com-Kalendern und habe festgestellt, dass Sie Folgendes tun können, um auf einen der nicht standardmäßigen Kalender zuzugreifen:

Set oFolder = oNameSpace.Folders.Item("account address").Folders.Item("Calendar").Folders.Item("Other calendar name").Items.Add(olAppointmentItem) 

Konnte nichts davon ohne Ihre Post, Joshua getan haben. Vielen Dank!

Verwandte Themen