K
Keith G Hicks
I have a document (word 2003) with 3 sections. The first and 3rd sections
are protected as a form. The 2nd is not protected. There are form fields in
the first section that are populated with data from code from an MS Access
app. There are also form fields that are not set up with data from the
database. These are manually filled in by a user after the document is
created. The 2nd section (the one that is not protected) has a single
bookmark in it that is also to be populated via code. This bookmark is not a
form field because a person's initials get posted to it and then autotext
turns that into a signature. The form fields in section 1 are filling in
just fine. The 3rd section just has text in it that needs to remain
unchanged when the user edits the form fields in the resultant document.
The trouble is that when the code tries to insert the initials into the
bookmark in section 2 I get an error saying the document is protected.
Here's the code. Can anyone tell me what's wrong? I think I'm not actually
getting to section 2. But not sure.
Set docWord = objWord.Documents.Add(Template:=sWordFormsPath &
"MyTemplate.dot")
With docWord.FormFields
.Item("WholeName").Result = sCWName
.Item("SSN").Result = sCSSN
.Item("CustomerName").Result = sCCustName
.Item("DOB").Result = sCDOB
.Item("ClientAge").Result = sCAge
End With
If Not fncIsBlank(sCCust) Then
If MsgBox("Include Signature?", vbYesNo, "Signature Verify") = vbYes
Then
Set rngWord = docWord.GoTo(what:=wdGoToSection,
which:=wdGoToAbsolute, Count:=2)
Set rngWord = docWord.GoTo(what:=wdGoToBookmark,
Name:="CustSignature")
rngWord.InsertAfter sCCust
On Error Resume Next 'only necessary if autotext is not set for
this customer in the normal.dot template
rngWord.InsertAutoText
On Error GoTo fncMakeDocument_ERR
End If
End If
Thanks,
Keith
are protected as a form. The 2nd is not protected. There are form fields in
the first section that are populated with data from code from an MS Access
app. There are also form fields that are not set up with data from the
database. These are manually filled in by a user after the document is
created. The 2nd section (the one that is not protected) has a single
bookmark in it that is also to be populated via code. This bookmark is not a
form field because a person's initials get posted to it and then autotext
turns that into a signature. The form fields in section 1 are filling in
just fine. The 3rd section just has text in it that needs to remain
unchanged when the user edits the form fields in the resultant document.
The trouble is that when the code tries to insert the initials into the
bookmark in section 2 I get an error saying the document is protected.
Here's the code. Can anyone tell me what's wrong? I think I'm not actually
getting to section 2. But not sure.
Set docWord = objWord.Documents.Add(Template:=sWordFormsPath &
"MyTemplate.dot")
With docWord.FormFields
.Item("WholeName").Result = sCWName
.Item("SSN").Result = sCSSN
.Item("CustomerName").Result = sCCustName
.Item("DOB").Result = sCDOB
.Item("ClientAge").Result = sCAge
End With
If Not fncIsBlank(sCCust) Then
If MsgBox("Include Signature?", vbYesNo, "Signature Verify") = vbYes
Then
Set rngWord = docWord.GoTo(what:=wdGoToSection,
which:=wdGoToAbsolute, Count:=2)
Set rngWord = docWord.GoTo(what:=wdGoToBookmark,
Name:="CustSignature")
rngWord.InsertAfter sCCust
On Error Resume Next 'only necessary if autotext is not set for
this customer in the normal.dot template
rngWord.InsertAutoText
On Error GoTo fncMakeDocument_ERR
End If
End If
Thanks,
Keith