Kan ik excel koppelen aan outlook 365

Status
Niet open voor verdere reacties.

speedy1954

Nieuwe gebruiker
Lid geworden
25 dec 2009
Berichten
4
Hoi,
Ik wil in Excel een afspraak plannen en deze in de agenda van outlook overnemen.
Kan dit met een VBA of moet ik elke keer exporteren en weer opnieuw importeren?
Alvast bedankt Ger

Bestand is onderdeel van groter bestand met diverse functie op de achtergrond.
 

Bijlagen

  • Privelijst 2023 voorbeeld.xlsm
    30 KB · Weergaven: 21
Laatst bewerkt:
Dat kan prima met VBA. Post eens een bestandje, als je er zelf niet uit komt.
 
Dank voor de snelle reactie.
Ik heb een bestand aan het oorspronkelijk bericht gehangen.
 
Zal er, als het nog speelt (want nu iets minder snel), naar kijken :).
 
Ik heb er net naar gekeken, maar ik zie geen enkele code. Heb je zelf al eens wat geprobeerd, of gegoogled? Ik vond bijvoorbeeld code die ik zo kon bewerken dat ik met jouw bestand een afspraak kan inschieten in een agenda:
Code:
Sub ImportCalendar()
Dim NextRow As Integer, LeadDate As Date, DueDate As Date, Subject As String, Location As String, Body As String
    
    For NextRow = 2 To 3
        With Sheets("Blad1")
            Subject = .Cells(NextRow, "H").Value
            LeadDate = .Cells(NextRow, "A").Value + .Cells(NextRow, "C").Value
            DueDate = .Cells(NextRow, "B").Value + .Cells(NextRow, "D").Value
            LeadDate = .Cells(NextRow, "A").Value + .Cells(NextRow, "C").Value
            Location = .Cells(NextRow, "F").Value
            Body = .Cells(NextRow, "H").Value
        End With
        CreateCalEntry LeadDate, DueDate, Subject, Location, Body
    Next NextRow
End Sub

Code:
Function CreateCalEntry(LeadDate As Date, DueDate As Date, Subject As String, Location As String, Body As String)
Const olApItem = 1
Dim apOL As Object 'Outlook.Application, oItem As Object 'Outlook.AppointmentItem, objFolder As Object 'MAPI Folder '

    Set apOL = CreateObject("Outlook.Application")
    Set objFolder = GetFolder("Public Folders/All Public Folders/Shared Calender")
    Set oItem = apOL.CreateItem(olApItem)
    With oItem
        .Subject = Subject
        .Location = Location
        .Body = Body
        If IsDate(LeadDate) Then
            .Start = LeadDate
        Else
            .Start = DueDate
        End If
        .End = DueDate
        .Display
    End With

    Set oItem = Nothing
    Set apOL = Nothing
End Function

Code:
Public Function GetFolder(strFolderPath As String) As Object
'http://www.outlookcode.com/d/code/getfolder.htm '
Dim apOL As Object 'Outlook.Application '
Dim objNS As Object 'Outlook.NameSpace '
Dim colFolders As Object 'Outlook.Folders '
Dim objFolder As Object 'Outlook.MAPIFolder '
Dim arrFolders() As String
Dim I As Long

    strFolderPath = Replace(strFolderPath, "/", "\")
    arrFolders() = Split(strFolderPath, "\")
    Set apOL = CreateObject("Outlook.Application")
    Set objNS = apOL.GetNamespace("MAPI")
    On Error Resume Next
    Set objFolder = objNS.Folders.Item(arrFolders(0))
    If Not objFolder Is Nothing Then
        For I = 1 To UBound(arrFolders)
            Set colFolders = objFolder.Folders
            Set objFolder = Nothing
            Set objFolder = colFolders.Item(arrFolders(I))
            If objFolder Is Nothing Then
                Exit For
            End If
        Next
    End If
    Set GetFolder = objFolder
    Set colFolders = Nothing
    Set objNS = Nothing
    Set apOL = Nothing
End Function
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan