sjku76 asked in 電腦與網際網路軟體 · 1 decade ago

為啥巨集取代文字顏色不能成功?

我在WORD檔案裡搜尋"一生"的詞彙,全部選取後,把他變成藍色且14號字體,並把上述動作做成一個巨集儲存...但是完成後要再使用卻不能使用,我發現WORD的巨集好像無法對顏色做設定,以下是我的巨集碼,我並未出錯,請大大幫我鑑定一下,為什麼不能用...

Sub 巨集10()

'

' 巨集10 巨集

' 巨集錄製於 2008/11/12,錄製者 Colling

'

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting

With Selection.Find

.Text = "一生"

.Replacement.Text = "一生"

.Forward = True

.Wrap = wdFindContinue

.Format = True

.MatchCase = False

.MatchWholeWord = False

.MatchByte = True

.CorrectHangulEndings = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

Selection.Find.Execute Replace:=wdReplaceAll

ActiveWindow.ActivePane.VerticalPercentScrolled = 40

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting

With Selection.Find

.Text = "一生"

.Replacement.Text = "一生"

.Forward = True

.Wrap = wdFindContinue

.Format = True

.MatchCase = False

.MatchWholeWord = False

.MatchByte = True

.CorrectHangulEndings = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

End Sub

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    可以在取代的時候指定格式, 請試試在

    .Replacement.Text = "一生"

    下面加一行:

    .Replacement.Font.ColorIndex = wdBlue

    會把找到的一生變為藍色

    2008-11-13 13:13:26 補充:

    用錄製的話, 不會錄到設字型的部份, 要自己打入兩行敘述:

    Sub 巨集1()

    Selection.Find.ClearFormatting

    Selection.Find.Replacement.ClearFormatting

    With Selection.Find

    .Text = "一生"

    .Replacement.Text = "一生"

    2008-11-13 13:13:43 補充:

    .Replacement.Font.ColorIndex = wdBlue '字型顏色:藍色

    .Replacement.Font.Size = 14 '字型大小:14

    .Forward = True

    .Wrap = wdFindContinue

    .Format = True

    .MatchCase = False

    2008-11-13 13:13:48 補充:

    .MatchWholeWord = False

    .MatchByte = True

    .MatchAllWordForms = False

    .MatchSoundsLike = False

    .MatchWildcards = False

    .MatchFuzzy = False

    End With

    Selection.Find.Execute Replace:=wdReplaceAll

    End Sub

    2008-11-13 13:14:47 補充:

    To Nuee:

    貼在補充了

    • Login to reply the answers
  • 1 decade ago

    BlowExpress:

    我還以為可以,就把我的回答刪了。

    我試了,不行!

    可以寄你的樣本給我嗎?

    nuee168@yahoo.com.tw

    這個問題確實也困擾我蠻久了。

    2008-11-13 14:07:25 補充:

    確定可行!感恩!

    • Login to reply the answers
Still have questions? Get your answers by asking now.