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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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.
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top