Style of Formfield gets lost on Protecting Document.

M

Murali

I have created a simple form field like this:
Name (Style - 'TemplateLabel' ) : {FormField} (Style = 'Title1')

The style of form field ('Title1') is available when the document is in
UnProtected Mode. The Problem is the Style of formfield gets changed to
'TemplateLabel' on changing the document to Protected Mode.

Following is the code is invoked dynamically on click of a Command Button:

Private Sub GalleryImages_Click()
ActiveDocument.Unprotect Password:=""
Selection.TypeText Text:="Title" & vbTab & vbTab
Selection.Style = ActiveDocument.Styles("TemplateLabel")

Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput

With Selection.FormFields(1)
.Name = "Title1"
End With
Selection.Style = ActiveDocument.Styles("Title1")
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True
End Sub

Can anybody help to let know why the formfield style gets changed on
Protecting the document?

Thanks for your help
Murali
 
C

Cindy M.

Hi =?Utf-8?B?TXVyYWxp?=,

Which version of Word are we dealing with?

Is "Title1" a character style, or a paragraph style?

Is the text and formfields in a table?
I have created a simple form field like this:
Name (Style - 'TemplateLabel' ) : {FormField} (Style = 'Title1')

The style of form field ('Title1') is available when the document is in
UnProtected Mode. The Problem is the Style of formfield gets changed to
'TemplateLabel' on changing the document to Protected Mode.

Following is the code is invoked dynamically on click of a Command Button:

Private Sub GalleryImages_Click()
ActiveDocument.Unprotect Password:=""
Selection.TypeText Text:="Title" & vbTab & vbTab
Selection.Style = ActiveDocument.Styles("TemplateLabel")

Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput

With Selection.FormFields(1)
.Name = "Title1"
End With
Selection.Style = ActiveDocument.Styles("Title1")
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True
End Sub

Can anybody help to let know why the formfield style gets changed on
Protecting the document?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 
M

Murali

Thanks for looking into the issue.
1. We are using Word 2003.
2. The style of the label ("Name") is of type character and of the form
field ("Title1") is Paragraph.
3. The text & form fields are not in a table.

Look forward your reply, Murali
 
C

Cindy M.

Hi Murali,
1. We are using Word 2003.
2. The style of the label ("Name") is of type character and of the form
field ("Title1") is Paragraph.
3. The text & form fields are not in a table.
See if this KB article applies to your situation. The behavior you
describe seems to indicate it:

Incorrect Font Is Applied After a Style Is Applied to a Form Field
ID: 828501
http://support.microsoft.com/default.aspx?scid=kb;en-us;828501

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top