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

Gyp*_*psy 8 c# ms-word office-interop

如何写入Word文档中的特定位置,例如第5行,第50个字符?我搜索了几个小时,但找不到解决方案.

我在用 Microsoft.Office.Interop.Word

Fio*_*ala 4

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

ActiveDocument.Sentences(1).Characters(5).Select
Selection.Collapse
Selection.InsertBefore "added "
Run Code Online (Sandbox Code Playgroud)

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

Selection.Text = String(5, vbCrLf) 
Selection.Collapse wdCollapseEnd
Selection.Text = String(50, " ")
Run Code Online (Sandbox Code Playgroud)

但是,对于特定位置,我更喜欢一个文本框:

Set sh = doc.Shapes.AddTextbox(1, 10, 344, 575, 80)
sh.Name = "Course1"
Run Code Online (Sandbox Code Playgroud)

具有一些属性:

sh.Fill.Visible = False
sh.Line.Visible = False
sh.TextFrame.MarginLeft = 0#
sh.TextFrame.MarginRight = 0#
sh.TextFrame.MarginTop = 0#
sh.TextFrame.MarginBottom = 0#
Run Code Online (Sandbox Code Playgroud)