簡體   English   中英

Word刪除空白行

[英]Word delete blank lines

我想清理自動生成的Word文檔。

本文檔包含幾個表,並且每個表之間都有許多空白行。 我想開發一個宏,每個表之間僅保留一個空白行。

我不知道是否可以做到。 現在,我堅持:

Dim i As Integer
Dim tTable As Table
For i = 0 To ActiveDocument.Tables.Count
    Set tTable = ActiveDocument.Tables.Item(i)

    ' ???

Next

任何想法?

我發現了如何做到這一點:

Dim ParagraphToTrim As Range
Dim tTable As Table
Dim aTables() As Table

Set aTables = ActiveDocument.Tables

For Each tTable In aTables
    ' Supply a Start and End value for the Range.
    Set ParagraphToTrim = ActiveDocument.Range(tTable.Range.Next(Unit:=wdParagraph).Start, tTable.Range.Next(Unit:=wdTable).Start)
    ' Keep at least a paragraph between each table
    If ParagraphToTrim.Paragraphs.Count > 1 Then
        With ParagraphToTrim
            ' Change the start of the range
            .MoveStart Unit:=wdParagraph
            .Delete
        End With
    End If
Next

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM