+ Reply to Thread
Results 1 to 7 of 7

Create appointment: Method * of object * Failed / Runt time error

  1. #1
    Registered User
    Join Date
    12-06-2017
    Location
    Sweden
    MS-Off Ver
    Office 2016
    Posts
    6

    Create appointment: Method * of object * Failed / Runt time error

    Hi, I have a problem that stops us from sending appointments to our technichians. I have a macro written in Excel 2016 that create appointments in Outlook (and a lot of other things) which works fine on my computer and others. Now one person has a new computer (also Excel 2016) where everything works except the red rows below.


    With oFolder
    Set olApt = oApp.CreateItem(olAppointmentItem)
    olApt.MeetingStatus = olMeeting
    With olApt
    .Start = Cells(6, 3).Value + Cells(8, 3)
    .End = Cells(6, 3) + DateAdd("n", Cells(10, 3).Value, Cells(8, 3))
    .Subject = SR + " " + Cells(12, 6) + " " + Cells(8, 6)
    .Location = Cells(10, 6)
    .Body = Cells(6, 6) + vbNewLine + vbNewLine + Cells(16, 3)
    .BusyStatus = olFree
    .ReminderMinutesBeforeStart = Cells(12, 3)
    .ReminderSet = True

    ' get the recipients
    Dim RequiredAttendee, OptionalAttendee, ResourceAttendee As Outlook.Recipient
    Set RequiredAttendee = .Recipients.Add(Cells(14, 3).Value)
    RequiredAttendee.Type = olRequired
    'Display 'Ta bort denna om bokningen ska skickas automatiskt
    .Send
    .Save
    .Move oFolder
    End With

    We get an error message:
    "Run-time error '-2147417851 (80010105)':
    Method 'Location' of object '_AppointmentItem' failed


    I have googled and I found a lot of matches but havn't been able to solve it. Does anybody know what I can do or have any suggestions?

    Thank you in advance,
    Johan

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Create appointment: Method * of object * Failed / Runt time error

    Hi,

    What's the actual value of Cells(10, 6) when the code is running? (tested via debug.print rather than by what you think it should be )
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    12-06-2017
    Location
    Sweden
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Create appointment: Method * of object * Failed / Runt time error

    Thanks for you reply. I added the code Debug.Print Cells(10, 6) above .Location = Cells(10, 6). When I step through the immediate window says e.g. "Bollbrogatan 1 257 33 Helsingborg" which is the correct street and postal address.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Create appointment: Method * of object * Failed / Runt time error

    Are you testing that on the machine where the code fails?

  5. #5
    Registered User
    Join Date
    12-06-2017
    Location
    Sweden
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Create appointment: Method * of object * Failed / Runt time error

    Very strange. In one of my hundreds of googling I found someone who wrote that if they register the string as a variable and then add it to location (or the To-address in that example) it would work. And actually it did. I added before the "With":
    Location = Cells(10,6)
    and then in the With:
    .Location = Location
    And it worked!
    If anyone knows why that matters I would be pleased to now. For me it should be the same thing but obviously it's not.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Create appointment: Method * of object * Failed / Runt time error

    That is indeed strange! Out of curiosity, does this also work
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-06-2017
    Location
    Sweden
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Create appointment: Method * of object * Failed / Runt time error

    You're a genius! Yes, that also worked. So Excel didn't interpret my address in the cells as strings? The cells are all formatted as General. Your conversion did the trick.

+ 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. [SOLVED] Run-time error 440: Method create of object 'PivotCaches' failed
    By JohnMurray in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2017, 08:33 AM
  2. Runt time error 1004 Method "Copy of object'_Worksheet failed"
    By mohansoft in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 10-20-2016, 03:15 AM
  3. [SOLVED] run time error method value of object range failed
    By gloger in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-27-2015, 04:56 AM
  4. Run-time error '1004' Method 'Range' of object'_Global' failed
    By mbie451 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-11-2014, 01:40 PM
  5. Addon error : Run-time error '1004': Method 'MacroOptions' of object '_Application' failed
    By jtcoleman in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 02-05-2014, 12:23 PM
  6. Run-time-error 1004 -- Method 'Range' of object '_Global' failed
    By tilleyd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2012, 10:55 PM
  7. [SOLVED] run-time error, method 'paste' of object - worksheet failed.
    By Carl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2006, 12:15 AM

Tags for this Thread

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