> What is the clean way to insert a field from a macro?
> I tried to record it, but the result was:
> Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
> _
> "AUTHOR ", PreserveFormatting:=True
> Thanks.
What is the problem with that code as far as you are concerned? What is
"unclean" about it?

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
Klaus Linke - 25 Mar 2007 13:58 GMT
>> What is the clean way to insert a field from a macro?
>> I tried to record it, but the result was:
>> Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
>> Text:= _
>> "AUTHOR ", PreserveFormatting:=True
> What is the problem with that code as far as you are concerned? What is
> "unclean" about it?
I guess Flint's point is that this would be cleaner:
Selection.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldAuthor, _
Text:= "", _
PreserveFormatting:=True
The macro recorder isn't perfect... Who knew? <g>
Klaus