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
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