Problem : Word 2000 document automation from Microsoft Access 2000
I am trying to automate the creation of ‘skeleton’ Microsoft Word reports from within Microsoft Access using VBA
For new records in the database, I have a button on a form that, when clicked, attempts to create and save a skeleton report based on a Word Template. The template is protected for Forms entry.
… code snippet
Dim objWordApp As Word.Application
Dim objWordDoc As Word.Document
If IsNull(Me.CourseReport) Then
objComDlg.Filter = “Microsoft Word Documents (*.doc)|*.doc”
objComDlg.DialogTitle = “Save Training Course Report As”
objComDlg.MaxFileSize = 255
objComDlg.ShowSave
Set objWordDoc = objWordApp.Documents.Add(“
objWordDoc.Bookmarks(“txtC
‘ the following line throws an exception – “Run-time error ‘4605’: This method or property is not available because the object refers to a protected area of the document.”
objWordApp.Selection.TypeT
objWordDoc.SaveAs objComDlg.FileName
End If
What is going wrong here?
Solution : Word 2000 document automation from Microsoft Access 2000
If you wanted to enter text at a bookmark it would be simpler to do
objWordDoc.Bookmarks(“txtC
but that would also give an error in the case of a form field for the same reason that Select and TypeText do – i.e. the bookmark includes the formfield itself as well as the displayed text.
For form fields do this:
objWordDoc.FormFields(“txt


