1. "Username FormField" - your code inserts a Field, not a FormField. A
formfield is used for user input.
2. "can i get it into a footer" Yes. You do not state WHAT footer, so I
will use the Primary footer of Section 1.
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary) _
.Range.Fields.Add _
Range:=ActiveDocument.Sections(1) _
.Footers(wdHeaderFooterPrimary) _
.Range, _
Type:=wdFieldUserName
This could certainly be written shorter, by using a range object (and numeric
constants), like:
Dim r As Range
Set r = ActiveDocument.Sections(1).Footers(1).Range
r.Fields.Add Range:=r, Type:=60
Both code snippets do exactly the same thing. They REPLACE the footer
content.with the UserName field. If you need to put the field within
existing content of the footer, that is another - not too difficult - issue.
Do you need the myField as an object?
Office_Novice wrote:
>I would like to insert the UserName FormField into footer programmatically.
>
>this code works but can i get it into a footer?
>
>Selection.Collapse Direction:=wdCollapseStart
>Set myField = ActiveDocument.Fields.Add(Range:=Selection.Range, _
> Type:=wdFieldUserName)
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200802/1