【发布时间】:2020-09-21 12:30:58
【问题描述】:
我在文档中的任意点(绝对位置)插入一个形状(在 Word 中命名为文本框:Word > 插入 > 展开“文本框”> 绘制文本框),其中填充了内容(例如文本、表格带文字,...)。但现在我想将光标移动到形状中的第一个位置。我该怎么做?
我的尝试(在我看来,注释掉时它会将光标放在文档的第一个位置):
Dim objWord As Application
objWord = GetObject(, "Word.Application")
For i As Integer = 1 To objWord.ActiveDocument.Shapes.Count
objWord.ActiveDocument.Shapes(i).TextFrame.TextRange.Select() 'select the whole textbox
'Dim objRange As Range = objWord.ActiveDocument.Range
'objRange.SetRange(objWord.ActiveDocument.Shapes(i).TextFrame.TextRange.Start, objWord.ActiveDocument.Shapes(i).TextFrame.TextRange.Start) 'position cursor is out of the shape
'objRange.Select()
Next
【问题讨论】: