'The operation failed' error message

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I get an 'The operation failed' error message in the line in red below. At one point i restarted my PC and it all worked, but now it has come back again. Has anyone ever come across this issue?

Rich (BB code):
    For Each cell In Range("A3:A" & intLastFilteredRow).SpecialCells(xlCellTypeVisible).Cells
        Workbooks(strFilename).Activate
        blnSendEmail = False
        strSurveyID = cell.Value
        strLandParcelID = cell.Offset(0, 1).Value
        dteSurveyDate = cell.Offset(0, 2).Value
        strAssetRef = cell.Offset(0, 3).Value
        strSurveyorName = cell.Offset(0, 8).Value
        dteCancellationDate = cell.Offset(0, 13).Value
        dteRequestLastSentDate = cell.Offset(0, 17).Value
        cell.Offset(0, 17).Select 'Needed below in order to insert date.
        
        ThisWorkbook.Activate
        
        If Trim(strSurveyorName) <> "" Then
            With Sheets("Surveyor Info").Range("A:A")
                Set rng = .Find(What:=strSurveyorName, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
                If Not rng Is Nothing Then
                    Application.Goto rng, True
                    strEmailAddress = rng.Offset(0, 6)
                Else
                    strEmailAddress = ""
                End If
            End With
        End If
        
        If dteRequestLastSentDate = "00:00:00" Then
            blnSendEmail = True
        ElseIf CInt(Date - dteRequestLastSentDate) > 7 Then
            blnSendEmail = True
        End If

        If blnSendEmail = True Then
            If strEmailAddress <> "" Then
                Set oApp = New Outlook.Application
                Set olSession = oApp.GetNamespace("MAPI")
                Set olMail = oApp.CreateItem(olMailItem)
            
                With olMail
                    Set myInspector = .GetInspector
                    Set myRecipient = .Recipients.Add(strEmailAddress)
                    .SentOnBehalfOfName = "EWCNorth_HealthSafety@aecom.com"
                    .Subject = "Proforma Request for Land Parcel ID:" & strLandParcelID
                    If dteRequestLastSentDate <> "00:00:00" Then
                        If CInt(Date - dteRequestLastSentDate) > 7 Then
                            .Body = "Hello, ... " 
                        End If
                    Else
                        .Body = "Hello, ..." 
                    End If
'                    .Display
'                    .Send
                End With
                Set myRecipient = Nothing
                Set myInspector = Nothing
                Set olMail = Nothing
                Set olSession = Nothing
                Set oApp = Nothing
                Workbooks(strFilename).Activate
                ActiveCell.Value = Now
                x = x + 1
            Else
                j = j + 1
            End If
        End If
    Next cell
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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