+ Reply to Thread
Results 1 to 4 of 4

Excel (2013 Germ.Vers) macro to create appointments in Outlook (2013) with runtime error

Hybrid View

  1. #1
    Registered User
    Join Date
    12-06-2011
    Location
    Rosenheim, Germany
    MS-Off Ver
    Excel 2007
    Posts
    19

    Unhappy Excel (2013 Germ.Vers) macro to create appointments in Outlook (2013) with runtime error

    Hello,

    I’ve searched and found may posts about sending appointment from excel sheet to outlook.
    This Macro “Add_To_Outlook” was found here in forum and working almost perfect.
    One thing is not working that Macro has runtime error 438 by “If olApptSearch = olAppointment”.
    If I take this out and run Macro twice I will have duplicated appointments.
    I am new to VBA so I don't understand half of this code as I copied from excel forum.
    Explanation to sheet “1 source”:
    Column B (from B2) containing date, column C (from C2) containing subject. This appointments are all day events “AllDayEvent = True” (no starting and no ending time).
    How to adjust this excel macro to create appointments in outlook calendar “Schulung” from excel sheet without duplicates?


    Sub Add_To_Outlook()
    '!! Reference to Outlook object library required !!
        Dim olAppointment As Outlook.AppointmentItem
        Dim olApptSearch As Outlook.AppointmentItem
        Dim olApp As Outlook.Application
        Dim olFolder As Object
        Dim lngRow As Long, shtSource As Worksheet
        Dim NS As Outlook.Namespace
        Dim colItems As Outlook.Items
        Dim Appfound As Boolean
        Dim UseDate As Date
    
        'Get reference to MS Outlook
        On Error Resume Next
        Set olApp = GetObject(, "Outlook.Application")
        If Err.Number <> 0 Then
            Set olApp = CreateObject("Outlook.Application")
            On Error GoTo 0
        End If
     
        Dim MyCal As String
        MyCal = "Schulung"   ' change your calendar name here
        Set NS = olApp.GetNamespace("MAPI")
        Set olFolder = NS.GetDefaultFolder(olFolderCalendar)
        On Error Resume Next
        Set olFolder = olFolder.Folders(MyCal)
        'Set olFolder = NS.GetDefaultFolder(9) 'for Calender on my computer
        On Error GoTo 0
        Set shtSource = ActiveSheet
    
        For lngRow = 2 To shtSource.Cells(Rows.Count, 2).End(xlUp).Row
            Appfound = False
            Set olAppointment = olFolder.Items.Add
            UseDate = shtSource.Cells(lngRow, 2).Value
            With olAppointment
                .Subject = "" & shtSource.Cells(lngRow, 3)
                .Start = UseDate
                .AllDayEvent = True
                .ReminderSet = True
                Set colItems = olFolder.Items
                
                For Each olApptSearch In colItems
                   'If olApptSearch = olAppointment Then Appfound = True '==> here comes "Runtime Error 438"
                Next
                If Appfound = False Then
                    .Save
                Else
                    MsgBox "Appointment '" & .Subject & "' already exists. Not saved."
                End If
            End With
    
            Set olAppointment = Nothing
        Next lngRow
    End Sub

    Would appreciate any help you can give me on this.

    Many thanks in advance
    Excelianer
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-06-2011
    Location
    Rosenheim, Germany
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Excel (2013 Germ.Vers) macro to create appointments in Outlook (2013) with runtime err

    Hi everyone,
    I hope someone can help me.... how to adjust in posted code above “If olApptSearch = olAppointment Then Appfound = True” to run it whihout entering duplicate appointmnts o Outlook. My Office version is 2013 German version.

    Do you have similar or other suggestion?

    Thanks in advance for your helps...

  3. #3
    Registered User
    Join Date
    12-06-2011
    Location
    Rosenheim, Germany
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Excel (2013 Germ.Vers) macro to create appointments in Outlook (2013) with runtime err

    .... *“If olApptSearch = olAppointment Then Appfound = True”...
    Did any one try to run this makro?
    For any help or advices I am very thankfull

  4. #4
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: Excel (2013 Germ.Vers) macro to create appointments in Outlook (2013) with runtime err

    Try
    If olApptSearch.Class = olAppointment Then Appfound = True
    To mark "Solved" go to Thread Tools.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel 2013 and Outlook 2013
    By xlbeginnerxl in forum Excel General
    Replies: 3
    Last Post: 03-26-2014, 12:16 PM
  2. Create Excel Error on 2013 'End of statement Expected.
    By ryanlcs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2013, 11:46 AM
  3. Excel Macro/VBA to create multiple outlook appointments with required attendees
    By bradliggett in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-28-2013, 03:10 PM
  4. Recording Macro to create a Pivot Table in Excel 2013: run time error 5 invalid procedure
    By developerstew in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-25-2013, 07:17 AM
  5. Excel macro to create appointments in outlook calandar
    By John Pateman-Gee in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-19-2012, 12:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1