A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

trouble with a form with protected sections



 
 
Thread Tools Display Modes
  #1  
Old October 16th, 2004, 03:21 AM
Keith G Hicks
external usenet poster
 
Posts: n/a
Default trouble with a form with protected sections

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


  #2  
Old October 20th, 2004, 07:52 PM
Cindy M -WordMVP-
external usenet poster
 
Posts: n/a
Default

Hi Keith,

Why not set a break point in your code so that you can see where the insertion
point actually is?

FWIW, you certainly don't need to first go to the section. For that matter,
you shouldn't even need to GoTo the bookmark:

objRefToTemplateWithAutoText.AutoTextEntries("Name OfEntry").Insert _
Whe=docWord.Bookmarks("TheName").Range, RichText:=True

Note: I've just tested, and this does work in an unprotected section of a
protected document.

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


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
modal windows AT Using Forms 3 November 21st, 2004 05:49 AM
Look up a related record in a second form Jim Dublin New Users 2 November 6th, 2004 09:37 AM
Cursor Positioning Colin Hammond General Discussion 3 November 2nd, 2004 08:42 PM
Tab Order & form sections Randy K. Using Forms 2 August 26th, 2004 06:39 PM
Passing value to modal child form in MS Access using VBA? Grahammer Using Forms 6 July 4th, 2004 11:53 PM


All times are GMT +1. The time now is 07:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.