Quote:
Originally Posted by gmayor
It is difficult to understand the point of this, but the following macro will work, provided you attach the datasource to the blank document:
Code:
Sub Macro1()
Dim i As Integer
Dim orng As Range
With ActiveDocument.MailMerge.DataSource
For i = 1 To .FieldNames.Count
Set orng = ActiveDocument.Range
orng.Collapse 0
orng.Fields.Add orng, wdFieldMergeField, Chr(34) & .FieldNames(i), False
Set orng = ActiveDocument.Range
orng.Collapse 0
orng.InsertParagraphAfter
Next i
End With
Set orng = Nothing
End Sub
|
When I ran this, each field name had a space at the end, which didn't match my DataSource (e.g.:
«NO_OF_DAYS ») so I removed just the "
Chr(34) & " from line 8, then they came out correctly (
«NO_OF_DAYS»).
Thanks!
P.S.: WOW, I haven't used BBCode in ages!