Inserting field from a VB macro

F

Flint

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.
 
J

Jonathan West

Flint said:
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?


--
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
 
K

Klaus Linke

Jonathan West said:
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
 

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