I have this code:
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")
oDoc.Bookmarks.Item("Hello").Range.Text = "Hello Word"
It produces this error:
The requested member of the collection does not exist
why does not it work? the code is wrong or some setting in Word?
The offending code appears to be the following
It appears that there is no book mark by the name of
"Hello" in that document. Hence this line of code throws an exception.
To fix this you need to use the correct identifier for this book mark or add a new one if the one you want isn't present