现有书签似乎处于只读模式(Vb.net)

现有书签似乎处于只读模式(Vb.net),vb.net,Vb.net,我什么都试过了,但我不能在书签上写字 Dim oWord As Microsoft.Office.Interop.Word.Application Dim oDoc As Microsoft.Office.Interop.Word.Document oWord = CreateObject("Word.Application") oWord.Visible = True oDoc = oWord.Documents.Add("C:\Users\mattia\Documents\Test.dotx

我什么都试过了,但我不能在书签上写字

Dim oWord As Microsoft.Office.Interop.Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add("C:\Users\mattia\Documents\Test.dotx")
因此,我尝试检查ContentControls.Count是否大于0,并且属性Retrieve告诉我现有书签的正确数量;但例如,使用:

oDoc.Bookmarks.Item("Hello").Range.Text = "Hello Word"
oDoc.Fields.Item(0).Result = "HelloWord"

我总是有同样的错误:“请求的集合成员不存在”

您的代码工作正常,除了部分
oDoc.Fields.Item(0).结果
应该是
oDoc.Fields.Item(0).Result.Text
我总是有相同的错误…将文件移动到另一个文件夹,如
C:
C:\Users
中,然后检查书签是否存在。“请求的收藏成员不存在”。。。我确信my.dotx中的标记是:“Hello”只使用前6行代码(..oDoc.Bookmarks.Item(“Hello”).Range.Text=“Hello Word”)。别用别的东西
oDoc.ContentControls.Item("Hello").Range.Text = "Hello Word"