我在Microsoft Word 2003中有一个包含大约1000个字母的文件夹。
这些字母具有类似布局的标题,但内容可以不同。标题的布局是2列2行表,但第2列合并了单元格。在头表之前总是有两个回车符。
我需要进入每个字母并删除第一列和第一个单元格的内容,以及第二列的内容,将其替换为空。
发布于 2013-01-29 22:00:33
您可以使用VBA宏遍历所有文件并将更改应用到表中,例如,使用以下代码:
Sub CleanHeader()
Dim strDirectory As String
Dim strFile As String
strDirectory = "C:\tmp\"
strFile = Dir(strDirectory & "*.doc")
Do While strFile <> ""
Dim oDoc As Document
Dim oTable As Table
Set oDoc = Documents.Open(FileName:=strDirectory & strFile)
Set oTable = oDoc.Tables(1) ' get the correct table here
oTable.Columns(1).Delete ' deletes an entire column
oTable.Cell(1, 2).Range.text = "" ' empties a cell
oDoc.Close SaveChanges:=True
strFile = Dir
Loop
End Subhttps://stackoverflow.com/questions/14584207
复制相似问题