English 中文(简体)
内容提要 仅限VBA
原标题:Clear ContentControl Content only VBA

在一份文字文件中,大约有100个Content Controls (CC),有适当的标题和名称。 然而,只想明确多功能闭关方案的内容,使闭关委员会本身保持下去。 请只注意内容。 DELETE和 IED的功能消除了《刑法》的内容,因此不能保留《刑法》的内容。 想要明确内容的是第11节,第23节,第45节,第24节, Apple01。 下面是我写的:

Sub ClearCCs_Contents()
  Dim CC As ContentControl
  For Each CC In ActiveDocument.ContentControls
      CC.Range.Text = ""
  Next CC
End Sub

is that possible that i replace the "ActiveDocument.ContentControls" with a list of CC tags that i stated above? or is there any other direct simple approaches?

主要议题:利用标签/名称编制内容控制清单,并处理清单中项目内容明确的内容。

问题回答
  • Use Title or Tag property to identify the desired CC
Sub ClearCCs_Contents()
  Dim CC As ContentControl, i As Long, arrCC
  Const CC_LIST = "Section11,Section23,Section45,Section24,AppleID01"
  arrCC = Split(UCase(CC_LIST), ",")
  For Each CC In ActiveDocument.ContentControls
    For i = LBound(arrCC) To UBound(arrCC)
        If UCase(CC.Title) = arrCC(i) Then
         If UCase(CC.Tag) = arrCC(i) Then
            CC.Range.Text = ""
            Exit For
        End If
    Next
  Next CC
End Sub

enter image description here





相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签