#1
|
|||
|
|||
How to Insert all merge fields into a blank document
I have a CSV data source that contains over 50 merge fields. When creating forms I often have to scroll endlessly to the bottom of the list to insert the fields I want to use in the form.
Is there a way to insert every merge field into a blank document without having to do it manually? For example: <<FirstName>> <<MiddleName>> <<LastName>> Thanks Last edited by Joe Fox; 08-30-2019 at 01:30 PM. |
#2
|
||||
|
||||
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
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thank you so much. This will be a great time saver for me.
|
Tags |
insert all merge fields |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail merge all fields into 1 document with rules | MP1989 | Mail Merge | 6 | 06-27-2018 04:43 PM |
insert blank page in document | Patryk | Word VBA | 1 | 01-22-2016 03:11 AM |
insert fields mail merge in vba | tariqaleed2 | Word VBA | 6 | 08-21-2014 12:21 AM |
How to Insert a Clear, Blank page without Lines and Numbers in a Pleading Document | Dirigo | Word | 5 | 09-30-2011 08:08 AM |
delete blank pages from mail merge document | blusea | Word | 0 | 12-17-2010 06:10 PM |