- 帖子
- 47
- 主題
- 19
- 精華
- 0
- 積分
- 82
- 點名
- 0
- 作業系統
- win
- 軟體版本
- xp
- 閱讀權限
- 20
- 註冊時間
- 2014-7-4
- 最後登錄
- 2021-9-4
|
Word VBA 指定範圍取代問題
各位高手好~
我寫了一個Function 來執行指定範圍、指定文字、指定底色的取代
可是執行時發現並沒有辦法指在指定範圍中進行取代 而是會變成整篇取代- 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
複製代碼 有人可以幫忙解決嗎~~~
謝謝 |
|