I am trying to open a word doc, make some changes where I have placed bookmarks and then save the document. I tried to follow the example found support.microsoft.com/default.aspx?scid=kb;EN-US;Q3316383 but get the following error.
This Range can not be deleted
I have confirmed that my book mark is getting recognized because I can read it in to the application. I also have the
Imports Word
at the top of the appplication.
Can someone help me out? Below is my code.
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim strText As String
'Start Word and open the document template.
oWord = CreateObject("Word.Application")
oWord.Visible = False
oDoc = oWord.Documents.Add("C:\text.doc")
strText = "Text Name"
Dim oRange As Range
If oDoc.Bookmarks.Exists("fldAddName") Then
oRange = oDoc.Bookmarks.Item("fldAddName").Range
oRange.Text = strText
End If
MTmace
This Range can not be deleted
I have confirmed that my book mark is getting recognized because I can read it in to the application. I also have the
Imports Word
at the top of the appplication.
Can someone help me out? Below is my code.
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim strText As String
'Start Word and open the document template.
oWord = CreateObject("Word.Application")
oWord.Visible = False
oDoc = oWord.Documents.Add("C:\text.doc")
strText = "Text Name"
Dim oRange As Range
If oDoc.Bookmarks.Exists("fldAddName") Then
oRange = oDoc.Bookmarks.Item("fldAddName").Range
oRange.Text = strText
End If
MTmace