Helo,이 코드에 따르면 (Visual Basic for word) : 코드는 저에게 적합하지만 제가 원하는 것은 아닙니다 ...
문제는 색이있는 텍스트 (예-> 빨간색으로 색이 지정된 텍스트) 만 선택하고 빨간색으로 색이 지정된 모든 단어를 선택하는 것입니다. 나는 모든 것을 시도했지만 그것은 나를 위해 작동하지 않기 때문에 매우 좌절합니다. 내 목표는 예를 들어 기본 문서에서 파란색 텍스트 또는 빨간색 텍스트 만 선택하는 것입니다 . 문서에있는 색상은 단조롭습니다. 빨강, 파랑, 녹색, 흰색, whele 및 가장 중요한 텍스트는 하늘색으로 채색됩니다. 글을 써서 미안하고 수고에 감사드립니다.
// 텍스트 색상 바꾸기 //
Sub ChangeColorWithReplace()
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorRed
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = -603914241
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
시작하기위한 몇 가지 코드는 다음과 같습니다.
Sub CopyRedContent()
Application.ScreenUpdating = False
Dim DocSrc As Document, DocTgt As Document
Set DocSrc = ActiveDocument: Set DocTgt = Documents.Add
With DocSrc.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Format = True
.Font.Color = RGB(255, 0, 0)
.Forward = True
.Wrap = wdFindStop
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While .Find.Execute
DocTgt.Range.Characters.Last.FormattedText = .FormattedText
DocTgt.Range.InsertAfter vbCr
If .Information(wdWithInTable) = True Then
If .End = .Cells(1).Range.End - 1 Then
.End = .Cells(1).Range.End
.Collapse wdCollapseEnd
If .Information(wdAtEndOfRowMarker) = True Then
.End = .End + 1
End If
End If
End If
If .End = ActiveDocument.Range.End Then Exit Do
.Collapse wdCollapseEnd
Loop
End With
Set DocSrc = Nothing: Set DocTgt = Nothing
Application.ScreenUpdating = True
End Sub
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다