且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在特定位置的Word文档中添加文本?

更新时间:2023-10-09 14:42:46

如果您对更简单的句子而不是行感到满意:

If you are content with the more simple sentence, rather than lines:

ActiveDocument.Sentences(1).Characters(5).Select
Selection.Collapse
Selection.InsertBefore "added "

VBA中的五个段落和50个空格

Five paragraphs and 50 spaces in VBA

Selection.Text = String(5, vbCrLf) 
Selection.Collapse wdCollapseEnd
Selection.Text = String(50, " ")

但是,对于特定位置,我希望使用文本框:

However, for a particular position, I would prefer a textbox:

Set sh = doc.Shapes.AddTextbox(1, 10, 344, 575, 80)
sh.Name = "Course1"

具有一些属性:

sh.Fill.Visible = False
sh.Line.Visible = False
sh.TextFrame.MarginLeft = 0#
sh.TextFrame.MarginRight = 0#
sh.TextFrame.MarginTop = 0#
sh.TextFrame.MarginBottom = 0#