正在尝试查找Word文档中的所有水平线并将其删除。遇到一些麻烦..。任何帮助都是非常感谢的。下面的代码。
Sub Replace()
Dim oShp As Shape
Dim i As Long
With ActiveDocument
For i = .InlineShapes.Count To 1 Step -1
With .InlineShapes(i)
oShp.Select
Selection.Delete
End With
Next
End With
End Sub
发布于 2020-12-18 02:17:10
您可以只迭代inlineShapes集合并仅删除类型为水平线的形状。
Public Sub DeleteHorizontalLines()
Dim docShape As InlineShape
For Each docShape In ActiveDocument.InlineShapes
If docShape.Type = wdInlineShapeHorizontalLine Then
docShape.Delete
End If
Next docShape
End Sub
如果有效,请让我知道
编辑:要将形状替换为文本,可以在删除之前添加文本。
添加下面这行:
docShape.Range.InsertAfter "Horizontal line"
在此行之前:
docShape.Delete
https://stackoverflow.com/questions/65346044
复制相似问题