The attempted operation failed. An object could not be found. Excel and Outlook 2010

aspinray

New Member
Joined
Jan 14, 2016
Messages
16
Hi,

I was wondering if someone can help!

I have recently had my PC upgraded to Windows 7 and Outlook and Microsoft Office upgraded to 2010 from 2007(i know what you're thinking!It's my workplace not me!)

Since having it upgraded some of my macro's have stopped working and I am not sure how to fix them, i am fairly new to VB!

Basically, I have a meeting schedule that I use to schedule people out into specific meetings. I click a button and it sends them an email from Outlook confirming date, time location etc.

Everything works fine, until outlook is involved and it would seem something to do with the upgrade.

When I click click my button "Update Responses" this should look in the folder in Outlook that the meeting responses ie. Accepted or Declined go to. It will then update my schedule with "Accepted or Declined" and a time stamp.

This has stopped working. However, if i use this on a PC that hasn't been upgraded it still works fine. I have pasted the code below and the error.

If you need anything else please let me know. Like i say i am fairly new to this.

I get the error - "Run-time error' -2147221233 (8004010f)':
The attempted operation failed. An object could not be found.

Below is the code - (bold/red is where it picked up the error and when hovering over "set Fldr" it says Nothing.

Sub GetFromMailbox()


ActiveSheet.Unprotect


Application.ScreenUpdating = False
Application.EnableEvents = False


Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
Dim myDestFolder As Outlook.Folder
Dim myattachments As Outlook.Attachments
Dim MyAttachment As Attachment

folname = Sheets("Overview").Range("tcode") & " Invites"
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.Folders("Mailbox - Learning and Development NE Training Invites").Folders("Inbox").Folders(folname)
Set myDestFolder = olNs.Folders("Mailbox - Learning and Development NE Training Invites").Folders("Inbox").Folders(folname).Folders("Processed")


For Each olMail In Fldr.Items
sessref = Right(olMail.Subject, 7)
If Left(sessref, 4) = Sheets("Overview").Range("tcode") & "-" Then
On Error Resume Next
response = Left(olMail.Subject, InStr(olMail.Subject, ":") - 1)

'***new - untested***
If Err.Number <> 0 Then
Err.Clear
On Error GoTo 0
GoTo skip2
End If
'*********************


On Error GoTo 0
If response <> "Undeliverable" And response <> "Out of Office AutoReply" And response <> "RE" Then
matchrow = WorksheetFunction.Match(sessref, Range("A:A"), 0)
row2 = matchrow + 40
user_name = olMail.SenderName
On Error Resume Next
matchid = WorksheetFunction.Match(user_name, Range("L" & matchrow & ":L" & row2), 0)
zz = 0
If Err.Number <> 0 Then
zz = Err.Number
GoTo skippy
End If
On Error GoTo 0
If olMail.SentOn > Cells(matchrow - 1 + matchid, 10) Then
Cells(matchrow - 1 + matchid, 10) = olMail.SentOn
Cells(matchrow - 1 + matchid, 9) = response
End If
skippy:
On Error GoTo 0
End If
skip2:
End If
If zz = 0 Then olMail.UnRead = False
'olMail.Move myDestFolder
Next olMail



Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing


Cells(1, 10) = Now
ActiveSheet.Protect
Application.EnableEvents = True


End Sub
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
2,005
It would suggest that there's a typo somewhere in the line. When it gets there and breaks. Make sure everything is spelt correctly. Not sure if it's case sensitive but to make sure, ensure all case is identical too. Compare to the actual names and ensure the variable folname is correct.
 

aspinray

New Member
Joined
Jan 14, 2016
Messages
16
Hi,

Thanks for the reply. I have checked and everything is the same. Like i say, if i open the same spreadsheet in Excel 2007 and outlook 2007 it works fine and no errors come up. Only when I use 2010? it's doing my head in!

Thanks in advance.
 

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
2,005
Have you checked the references are the same?

In the VBA window goto Tools > References. Make sure 2010's checked references are the same as 2007's
 

Watch MrExcel Video

Forum statistics

Threads
1,114,084
Messages
5,545,870
Members
410,711
Latest member
Josh324
Top