Reply
 
Thread Tools Display Modes
  #1   Report Post  
Shakeel Akhtar Shakeel Akhtar is offline
Junior Member
 
Posts: 2
Default Naming issue on saved mail merge documents

Hi

Having now learnt how to save mail merge documents as separate files, is there a way of naming each individual file based on a combination of the merged fields (e.g. First name, Surname and ID)?

Am using Word 2011 on a Mac (OX 10.8.5)

Thanks
  #2   Report Post  
Shakeel Akhtar Shakeel Akhtar is offline
Junior Member
 
Posts: 2
Default

Using the following VBA I can save the documents as Test 1, Test 2 etc.

I want to find out if I can use the name of the merge field in the VBA to refer to combined Mergefields.

Also what code do I need to add to bring up a message box to allow me to choose where to save the documents?

Thanks

Sub SaveIndividualMailMergeDocumnets()
'
' SaveIndividualMailMergeDocumnets Macro
'
'Sub BreakOnSection()
'Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection

'A mailmerge document ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To ((ActiveDocument.Sections.Count) - 1)

'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy

'Create a new document to paste text from clipboard.
Documents.Add
Selection.Paste

'Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1

ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs fileName:="Test_" & DocNum & ".docx"
ActiveDocument.Close
'Move the selection to the next section in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
naming documents automatically Millie[_2_] Microsoft Word Help 3 November 3rd 08 10:38 AM
best practices for naming documents Dave Hagan Microsoft Word Help 1 January 17th 08 04:37 PM
Mail Merge Issue BC Mailmerge 3 February 20th 07 09:14 AM
mail merge issue drewstein Microsoft Word Help 2 April 7th 06 06:29 PM
Automatically naming documents with data in form fields? AMG Microsoft Word Help 5 March 12th 06 10:03 PM


All times are GMT +1. The time now is 05:06 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"