VBA 매크로를 사용하여 Microsoft Word에서 스타일 검색을 실행하고 있습니다. 내 목표는 문서에서 발견 된 모든 스타일에 대해 특정 작업을 한 번 수행하는 것입니다.Microsoft Word VBA 매크로 - 단락 찾기 - 바꾸기 스타일
매크로는 두 개 이상의 단락이있는 문서에서 올바르게 작동하지만 매크로는 단 하나의 단락이있는 문서에서 스타일을 올바르게 경고하지 않습니다. 새로운 단락 기호를 입력하면 문서에 새로운 텍스트 나 스타일을 추가하지 않아도 스타일이 발견된다는 것은 이상한 것 같습니다. 단 하나의 빈 단락 기호 만 추가하면됩니다. 누구든지 내 매크로가 무엇이 문제인지 알고 어떻게 해결할 수 있습니까? 봐 주셔서 감사합니다.
Sub AlertAllStylesInDoc()
Dim Ind As Integer
Dim numberOfDocumentStyles As Integer
Dim styl As String
Dim StyleFound As Boolean
numberOfDocumentStyles = ActiveDocument.styles.count
For Ind = 1 To numberOfDocumentStyles
styl = ActiveDocument.styles(Ind).NameLocal
With ActiveDocument.Content.Find
.ClearFormatting
.text = ""
.Forward = True
.Format = True
.Style = styl
Do
StyleFound = .Execute
If StyleFound = True Then
' actual code does more than alert, but keeping it simple here'
MsgBox styl
GoTo NextStyle
Else
Exit Do
End If
Loop
End With
NextStyle:
Next
End Sub
감사합니다! 그것은 큰 도움이됩니다. – user773328