【发布时间】:2019-02-05 14:12:12
【问题描述】:
在 Word VBA 中,您可以使用 Selection.MoveLeft、Selection.MovRight 等设置和移动光标位置...
但是,在 Excel VBA 中尝试使用相同的方法时,我收到一条错误消息,提示“对象不支持此属性或方法。”
我已导入 Word 对象库参考。
如何在 Excel 应用程序上使用 VBA 移动 Word 文档上的光标位置。任何帮助将不胜感激。
代码: 设置 Doc = ActiveDocument.Content
With Doc.Find
.Execute FindText:="*", ReplaceWith:="NEW*"
End With
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdParagraph, Count:=11
Selection.MoveRight Unit:=wdWord, Count:=4
Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
Selection.Font.Bold = False
Selection.Font.Name = "Arial"
Selection.Font.Size = 9
【问题讨论】:
-
您是否创建了一个 Word 应用程序对象并将其与 Word 挂钩?可能对显示其余代码很有用。例如:software-solutions-online.com/vba-opening-word-from-excel