首页 > 解决方案 > 在链中使用多个样式

问题描述

我需要从 Excel 导入 Word 文档中的一些选项卡,为此我在 Excel 中使用了 VBA。

像这样的东西:

With SelDOCFile.Find
    .Forward = True
    .Wrap = wdFindContinue
    .Execute FindText:="\<FLAG\>"
    If .Found Then
     For Bank = 0 To Banks - 1
      SelDOCFile.InsertCaption Label:="Table", Title:=": Bank " & Bank _
         & " [Special" & Bank & "##A]", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
      SelDOCFile.HomeKey Unit:=wdLine
      SelDOCFile.EndKey Unit:=wdLine, Extend:=wdExtend
      SelDOCFile.Font.Size = 10
      SelDOCFile.Font.Bold = True
      SelDOCFile.Font.Italic = False
      SelDOCFile.Font.Name = "Arial"
      SelDOCFile.HomeKey Unit:=wdLine
      SelDOCFile.MoveRight Unit:=wdWord, Count:=6
      SelDOCFile.EndKey Unit:=wdLine, Extend:=wdExtend
      SelDOCFile.Style = ActiveDocument.Styles("SpecialFunc")
     ....
     Next Bank
  End If
End With

我想要的是在 [] 之间使用不同样式的文本编写 Title:="Table 1: Bank 0 [Special0##A]",但是这里的代码不能按预期工作。我有所不同,但样式没有完全应用,只有颜色、大小……发生了变化,但是当在 Word 中我将光标放在文本上时,它以与标题的其余部分相同的样式出现

有什么建议吗?谢谢

标签: excelvbams-word

解决方案


推荐阅读