0

这是我的代码,

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

在 ELSEIF 部分,我收到一条错误消息,提示“运行时错误 -2147024809 (80070057) 指定的值超出范围”。

它在 IF 部分运行良好。它是相同的代码,只是更改了作为文本传递的字符串。

4

1 回答 1

0

对不起,浪费你的时间点击这个问题。

就是这样,当工作表受到保护时,我试图编辑形状的文本。这是错误的原因。

应该早先阅读下面的链接。

Microsoft Excel VBA - 运行时错误“-2147024809 (80070057)”

于 2018-06-20T14:23:20.410 回答