Word VBA 指定範圍取代問題
各位高手好∼我寫了一個Function 來執行指定範圍、指定文字、指定底色的取代
可是執行時發現並沒有辦法指在指定範圍中進行取代 而是會變成整篇取代[code]Public Function myFun_findTxt2addShading( _
str_findTxt As String, _
range_myRange, _
str_repTxt As String, _
str_ShadingColor As String) As Boolean
Dim boolean_checkFound As Boolean
boolean_checkFound = False
range_myRange.Select
With Selection
.Find.ClearFormatting
.Find.Replacement.ClearFormatting
.Find.Text = str_findTxt
.Find.Replacement.Text = str_repTxt
.Find.Forward = True
.Find.Replacement.Font.ColorIndex = str_RepFontColor
.Find.Wrap = wdFindStop
Do While .Find.Execute
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = str_ShadingColor
boolean_check = True
Loop
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchByte = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.MatchAllWordForms = False
End With
findTxt_Shading = boolean_checkFound
End Function
Sub test()
a = myFun_findTxt2addShading("一", Selection.Range, "一", wdColorYellow)
End Sub[/code]有人可以幫忙解決嗎∼∼∼
謝謝 取代之後,範圍需不需要重新選取
頁:
[1]