Run-time error '-2114715382 (81f4010a)':
Method 'To' of object '_MailItem failed
this is the error message i am getting on this code - BUT only on one laptop. this code is used by multiple people using different office versions and different operating systesm (7 and 8.1). i am highlighting the line where the code stops. any suggestions would be great. the specs of teh laptop that this error is occuring on are - windows 8.1 and office 2013
Sub Button2593_Click()
Dim Fname As String
Dim EP As String
Dim FDate As String
Dim FQtr As String
Dim OutApp As Object
Dim Omsg As Object
Dim FQuarter As Integer
Dim myAddressee As String
Dim Msg As String, Ans As Variant
Msg = "HAVE YOU COMPLTED THE MOST RECENT HEALTH VISIT SECTION AT THE TOP OF REPORT? Have you set the re-visit dates for the Compliance Issues on the Business Review? And have you listed ALL LSM activities? Most Important: Are you connected to the G: and the VPN?"
Ans = MsgBox(Msg, vbYesNo)
Select Case Ans
Case vbYes
If Cells(247, 7) = "" Then
Msg = "Naughty Naughty - you did NOT do enough service times - Better get Back at 'er, Minimum service times is 5!! Better slow it down there cowboy"
Ans = MsgBox(Msg, vbOKOnly)
Exit Sub
Else
Application.ScreenUpdating = False
If Len(Sheets("fresh thinking audit").Range("c4")) > 0 Then
Score = Range("c411").Text
EP = Range("C4").Value
FQtr = Range("m12").Value
FDate = MonthName(Month(Date), True) & " " & DatePart("d", Date) & ", " & Year(Date)
Fname = "EP" & Sheets("fresh thinking audit").Range("c4").Value
FQuarter = WorksheetFunction.Ceiling(Month(Date) / 3, 1)
If Dir("c:\rbr", vbDirectory) = "" Then
MkDir ("c:\rbr")
End If
Sheets("fresh thinking audit").ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\rbr\" & Fname & " " & "MM" & " " & FDate & " " & Score & ".pdf", openafterpublish:=False
Sheets("SOS Timing").ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\rbr\" & Fname & " SOS Timing " & FDate & ".pdf", openafterpublish:=False
Sheets("Business Review").ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\rbr\" & Fname & " Business Review " & FDate & ".pdf", openafterpublish:=False
With Sheets("Unacceptable")
.Visible = True
.Copy
ActiveWorkbook.SaveAs _
Filename:="c:\rbr\" & EP & " Unacceptable " & FQtr & ".csv", _
FileFormat:=xlCSV
ActiveWorkbook.Close False
.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\rbr\" & Fname & " Unacceptable " & FDate & ".pdf", _
openafterpublish:=False
.Visible = True
End With
FileCopy "C:\rbr\" & EP & " Unacceptable " & FQtr & ".csv", "G:\RBR CSV Files\" & EP & " Unacceptable " & FQtr & ".csv"
FileCopy "C:\rbr\" & Fname & " " & "MM" & " " & FDate & " " & Score & ".pdf", "G:\rbr\" & Fname & " " & "MM" & " " & FDate & " " & Score & ".pdf"
FileCopy "C:\rbr\" & Fname & " SOS Timing " & FDate & ".pdf", "G:\rbr\" & Fname & " SOS Timing " & FDate & ".pdf"
FileCopy "C:\rbr\" & Fname & " Business Review " & FDate & ".pdf", "G:\rbr\" & Fname & " Business Review " & FDate & ".pdf"
FileCopy "C:\rbr\" & Fname & " Unacceptable " & FDate & ".pdf", "G:\rbr\" & Fname & " Unacceptable " & FDate & ".pdf"
Shell ("outlook")
Set OutApp = GetObject("", "outlook.application")
Set Omsg = OutApp.createitem(0)
myAddressee = "rons@mtygroup.com"
If Left(Sheets("fresh thinking audit").Range("n4"), 3) = "USA" Then
myAddressee = myAddressee
If Left(Sheets("fresh thinking audit").Range("n4"), 5) = "USA N" Then
myAddressee = myAddressee & ";Mears-denise@aramark.com"
End If
End If
If Left(Sheets("fresh thinking audit").Range("n4"), 5) = "Non-T" Then
myAddressee = myAddressee
End If
With Omsg
.To = Sheets("fresh thinking audit").Range("m4")
.cc = myAddressee
.Subject = "RBR on EP" & Sheets("fresh thinking audit").Range("c4") & " for " & FQtr
.body = "Restaurant Quality Report by " & OutApp.GetNamespace("MAPI").CurrentUser
.Attachments.Add "C:\rbr\" & Fname & " " & "MM" & " " & FDate & " " & Score & ".pdf"
.Attachments.Add "C:\rbr\" & Fname & " Business Review " & FDate & ".pdf"
.Attachments.Add "C:\rbr\" & Fname & " SOS Timing " & FDate & ".pdf"
'MsgBox .Address
If myAddressee = "rons@mtygroup.com" Then .Attachments.Add "C:\rbr\" & Fname & " Unacceptable " & FDate & ".pdf"
.send
End With
Call AddToOutlook
Macro1
Kill ("C:\rbr\" & Fname & " " & "MM" & " " & FDate & " " & Score & ".pdf")
Kill ("C:\rbr\" & Fname & " SOS Timing " & FDate & ".pdf")
Kill ("C:\rbr\" & Fname & " Business Review " & FDate & ".pdf")
Kill ("C:\rbr\" & Fname & " Unacceptable " & FDate & ".pdf")
Kill ("C:\rbr\" & EP & " Unacceptable " & FQtr & ".csv")
End If
End If
Case vbNo
GoTo Quit:
End Select
Quit:
End Sub
Bookmarks