run time error -2147024809 (80070057) the specified value is out of range with shape

5.7k Views Asked by At

Here is my code,

If ActiveWorkbook.Sheets("About tool").Range("G1").Value = 1 Then
    ActiveWorkbook.Sheets("About tool").Range("G1").Value = 0

    With ActiveWorkbook.Sheets("About tool").Shapes("Rounded Rectangle 2").TextFrame2
        If .HasText Then
            .TextRange.Delete
            .TextRange.Text = "Unlock All"
        End If
    End With

ElseIf ActiveWorkbook.Sheets("About tool").Range("G1").Value = 0 Then
        ActiveWorkbook.Sheets("About this tool ").Range("G1").Value = 1

        With ActiveWorkbook.Sheets("About tool").Shapes("Rounded Rectangle 2").TextFrame2
            If .HasText Then
                .TextRange.Delete
                .TextRange.Text = "Lock All"
            End If
        End With    
End If

Here on the ELSEIF section, I am getting an error saying "runtime error -2147024809 (80070057) the specified value is out of range".

It is working fine in the IF section. it is the same code with just change in the string passed as text.

1

There are 1 best solutions below

0
srt On

Sry, for wasting your time to click on this question.

It's just that, I was trying to edit the text of the shape when the sheet was protected. which is the cause for the error.

Should have read through the below link earlier.

Microsoft Excel VBA - Run-Time Error '-2147024809 (80070057)'