首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microsoft Word 2003中对Letters的大量更改

Microsoft Word 2003中对Letters的大量更改
EN

Stack Overflow用户
提问于 2013-01-29 21:34:25
回答 1查看 132关注 0票数 0

我在Microsoft Word 2003中有一个包含大约1000个字母的文件夹。

这些字母具有类似布局的标题,但内容可以不同。标题的布局是2列2行表,但第2列合并了单元格。在头表之前总是有两个回车符。

我需要进入每个字母并删除第一列和第一个单元格的内容,以及第二列的内容,将其替换为空。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-29 22:00:33

您可以使用VBA宏遍历所有文件并将更改应用到表中,例如,使用以下代码:

代码语言:javascript
复制
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 Sub
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14584207

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档