【发布时间】:2018-11-29 18:24:51
【问题描述】:
我正在尝试制作一个宏来根据级别添加具有不同样式的超链接,每个链接在表格中的新行上。
-
hyperlinktext1 (sub style1) (即粗体和大小 16)
1.1 hyperlinktext2 (sub style2) (即大小14)
我已确保样式存在并且适用于普通文本,但我无法将样式应用于使用 VBA 添加的超链接。
更改样式适用于我出于某种原因手动添加的超链接。
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"file.pdf", SubAddress:="", ScreenTip:="", TextToDisplay:="text1"
Selection.Style = ActiveDocument.Styles("Sub level1")
'new row
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.InsertRows 1
Selection.Collapse Direction:=wdCollapseStart
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"file2.pdf", SubAddress:="", ScreenTip:="", TextToDisplay:="text2"
Selection.Style = ActiveDocument.Styles("Sub level2")
有什么建议吗?
【问题讨论】: