簡體   English   中英

刪除隱藏的書簽中包含的文本

[英]Delete text contained by bookmarks that are hidden

我創建了一個模板,其中基於特定復選框(內容控件)的值,使用以下公式隱藏使用與復選框同名的書簽選擇的段落

Dim bookmark As String
Dim ctl As ContentControl
For Each ctl In ActiveDocument.ContentControls
    If ctl.Type = wdContentControlCheckBox Then
        If ctl.Checked = False Then
            bookmark = ctl.Tag
            Bookmarks(bookmark).Range.Font.Hidden = True
        Else
            bookmark = "hide_" & ctl.Tag
            Bookmarks(bookmark).Range.Font.Hidden = True
        End If
    End If
Next

我試圖剝離使用上述公式的段落的文檔(刪除它們)。
我試圖剝離隱藏段落的文檔,因為我想對段落進行編號,並且在不刪除它們的情況下,編號是指隱藏的段落。

使用隱藏字體查找和替換無濟於事,因為它是一種不同類型的隱藏內容。 我認為書簽保存在 xml 代碼中。

嘗試:

Dim CCtrl As ContentControl
For Each CCtrl In ActiveDocument.ContentControls
  With CCtrl
    If .Type = wdContentControlCheckBox Then
      If .Checked = False Then
        ActiveDocument.Bookmarks(.Tag).Range.Delete
      End If
    End If
  End With
Next

暫無
暫無

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

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