Populating Bookmark Fields

  • Thread starter Thread starter Gez
  • Start date Start date
G

Gez

Hi,

I've got a protected word document that only allows users to populate text
form fields. I want to be able to populate some of these text form fields
from access but I'm getting "runtime error 6028 The Range Cannot be
Deleted". I'm using the code below, any ideas?

Private Sub PrintWithWord()

Dim objWord As Word.Application

Set objWord = New Word.Application
objWord.Documents.Add _
Application.CurrentProject.Path & "\test.doc"
objWord.Visible = True

With objWord.ActiveDocument.Bookmarks
.Item("text1").Range.Text = "Some data here"
End With

Set objWord = Nothing
End Sub

Thanks,

Gez
 
Resolved this now. Should have used :

With objWord.ActiveDocument
.FormFields("Text1").Result = "Some Data Here"
 
Back
Top