외모를 당신의 스타일 "Body Text, bt"는 순수한 단락 스타일입니다. 즉, 전체 단락에만 적용된다는 의미입니다.
그러나 스크린 샷에는 두 번째 단락의 일부만 선택되어 있습니다. 전체 단락을 선택했는지 확인하고 단락의 일부에만 스타일을 적용해야한다면 스타일 "본문 텍스트 bt"를 링크 된 (단락 및 문자) 스타일로 만드십시오.
불 연속적 선택에 대한 프로그래밍 방식의 액세스는 매우 제한되어 있으며 이러한 선택은 Word UI를 사용하여 만 만들 수 있습니다. MSDN 문서 Limited programmatic access to Word discontiguous selections에 대한 자세한 내용이 나와 있습니다.
Sub BodyTextApply()
Dim oRange As Range
' create a temporary character style
ActiveDocument.Styles.Add "_TEMP_STYLE_", wdStyleTypeCharacter
' apply the temporary style to the discontiguous selection
Selection.Style = ActiveDocument.Styles("_TEMP_STYLE_")
Set oRange = ActiveDocument.Range
With oRange.Find
.ClearAllFuzzyOptions
.ClearFormatting
.ClearHitHighlight
.Style = ActiveDocument.Styles("_TEMP_STYLE_")
.Text = ""
.Wrap = wdFindStop
' search for all occurences of the temporary style and format the
' complete paraphraph with the desired style
Do While .Execute
oRange.Paragraphs(1).Style = ActiveDocument.Styles("Body Text,bt")
Loop
End With
' cleanup
ActiveDocument.Styles("_TEMP_STYLE_").Delete
End Sub
당신은 아마 원하는 : (이 링크 스타일을 만들어)에만 단락의 일부에 스타일을 적용하는 것은 당신이 아마 이런 해킹을 마련 할 필요가 원하는 것을하지 않으면
오류 처리를 추가하여 사용 된 임시 스타일이 최종적으로 문서에서 제거되는지 확인하십시오.
작동 Word 2007에서 정상적으로 작동합니까? – RBarryYoung