Set the style of a of a form field

A

Arthi

Hi ,
I need to create a .dot file , which will have a button. On click of the
button , a label is displayed and a form field is created. The Style (styles
and Formating) of the Label is of character type and the formfield is of
paragraph style .

Name ..............(FormField)
Address .............(Form Field)

the style of the label Name is (Label)
the style of the form field ll be (Name)

Now i am able to create the label and form field
But the style of the form field is not gettin set(which is very
important)... Please Help Me....



Selection.TypeText Text:="Name" & vbTab & vbTab & vbTab & vbTab & vbTab & _
vbTab
Set oRange = Selection.Range

Set oFormField = ActiveDocument.FormFields.Add(Range:=oRange,
Type:=wdFieldFormTextInput)

sName = "Name"
sStyle = "NameStyle"

With oFormField
.Name = sName
.Select
Selection.Style = ActiveDocument.Styles(sStyle)
End With

the style sStyle is created by going to
Format ->styles and Formattin ->NewStyle
Name = Name , Style Type -> Paragraph , style based on ->normal

..Select
Selection.Style = ActiveDocument.Styles(sStyle)
this is used to set the style of the formfield , which i assume is not
working.. :(
 
G

Graham Mayor

If this is a document template, why not simply insert the formatted form
field directly into the document? What's the point of this macro?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

Arthi

The FormFiled will be created on click of a button...
It needs to be dynamic . Create form filed only if user wants.
 

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