Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2019, 09:15 AM
Joe Fox Joe Fox is offline How to Insert all merge fields into a blank document Windows 7 64bit How to Insert all merge fields into a blank document Office 2016
Novice
How to Insert all merge fields into a blank document
 
Join Date: Aug 2019
Posts: 2
Joe Fox is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 09-02-2019, 01:12 AM
gmayor's Avatar
gmayor gmayor is offline How to Insert all merge fields into a blank document Windows 10 How to Insert all merge fields into a blank document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 09-03-2019, 11:02 AM
Joe Fox Joe Fox is offline How to Insert all merge fields into a blank document Windows 7 64bit How to Insert all merge fields into a blank document Office 2016
Novice
How to Insert all merge fields into a blank document
 
Join Date: Aug 2019
Posts: 2
Joe Fox is on a distinguished road
Default

Thank you so much. This will be a great time saver for me.
Reply With Quote
Reply

Tags
insert all merge fields

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Insert all merge fields into a blank document Mail merge all fields into 1 document with rules MP1989 Mail Merge 6 06-27-2018 04:43 PM
How to Insert all merge fields into a blank document 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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft