Word 宏 运行-time error '70': Permission denied

Word Macro Run-time error '70': Permission denied

我有一个宏可以删除图表、MS 表格、Excel 在 MS Word 中复制的表格和图像

Sub deleteNoise()
    Dim i As Integer

    With ActiveDocument
        For i = .Tables.Count To 1 Step -1
            .Tables(i).Delete
        Next i
        ActiveDocument.Shapes.SelectAll
        Selection.Delete
    End With
End Sub

它运行良好。直到我保存文件并尝试 运行 它,现在它只删除表格,当它到达图像时我得到以下错误。

Run-time error '70': Permission denied

那是 With 声明是垃圾。

Sub deleteNoise()
Dim objPic As InlineShape
For Each objPic In ActiveDocument.InlineShapes
objPic.Delete
Next objPic
    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
        tbl.Delete
    Next tbl
        Dim shp As Shape
ActiveDocument.Shapes.SelectAll
        Selection.Delete
End Sub