【问题标题】:Merge fields Bold Word 2010合并字段粗体字 2010
【发布时间】:2020-07-07 05:20:47
【问题描述】:

如何在 Microsoft Word 2010 中使所有合并字段变为粗体?请建议一种使用 VBA 的方法。此外,出现在 if 条件中的合并字段也必须加粗。

【问题讨论】:

    标签: vba ms-word mailmerge


    【解决方案1】:

    您可以使用查找和替换来录制宏。使用^d 查找所有字段并使用^& 替换为相同的文本,并将格式设置为粗体。在录制之前,通过选择全部并使用 Shift + F9 来切换所有域代码。记录此过程会产生以下 VBA 代码:

    Sub MergeBold()
    '
    ' MergeBold Macro
    '
    '
        Selection.WholeStory
        Selection.Fields.ToggleShowCodes
        Selection.MoveRight Unit:=wdCharacter, Count:=1
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        Selection.Find.Replacement.Font.Bold = True
        With Selection.Find
            .Text = "^d"
            .Replacement.Text = "^&"
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        Selection.WholeStory
        Selection.Fields.ToggleShowCodes
        Selection.MoveRight Unit:=wdCharacter, Count:=1
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-05
      • 2011-08-21
      • 1970-01-01
      • 2017-01-20
      • 2012-02-23
      • 2010-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多