0
어떤 cutomvariables가 문서에서 사용되는지 알아 내려고하고 있지만 머리말이나 꼬리말에 정의되어있는 경우에 문제가 있는지 알아볼 때 문제가 있습니다. 여기 머리글과 페이지 모두에서 단어로 된 텍스트 찾기
모든 customVariables을 통해 루프 내 하위입니다 : 여기Sub deleteCustomVarNotInUse()
Dim doc As Document
Set doc = ActiveDocument
For i = 1 To Documents(doc).CustomDocumentProperties.Count
If CustomProperties.findProperty(doc, Documents(doc).CustomDocumentProperties(i).name) Then
'Delete variable...
End If
Next i
End Sub
내가
here
Public Function findProperty(doc As Document, findText As String) As Boolean
On Error Resume Next
findProperty = False
Dim rng As Range
Dim intSecCount As Integer
Dim intHFType As Integer
Set rng = Documents(doc).Content
rng.Find.Execute findText:="DOCPROPERTY*" & findText, Forward:=True
If rng.Find.found = True Then
findProperty = True
Exit Function
End If
intSecCount = Documents(doc).Sections.Count
For intSection = 1 To intSecCount
With Documents(doc).Sections(intSection)
For intHFType = 1 To 3
Set rng = Documents(doc).Sections(intSection).Headers(intHFType).Range
rng.Find.Execute findText:="DOCPROPERTY*" & findText, Forward:=True
If rng.Find.found = True Then
findProperty = True
Exit Function
End If
Next intHFType
End With
Next intSection
End Function