Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2017, 01:12 AM
pttsv pttsv is offline Use a the data from a mail merge field Windows 10 Use a the data from a mail merge field Office 2013
Novice
Use a the data from a mail merge field
 
Join Date: Dec 2017
Posts: 2
pttsv is on a distinguished road
Default Use a the data from a mail merge field

Hey,
I was wondering if it would be possible to use the data from a merge field inside of a macro to change the datapath that the doc would be saved in. I'm working on a macro for my office, that merges patient info into a letter, but I was wondering if I can use the data from these fields in a macro to save the file under the name of the patient.
Thanks!
Reply With Quote
  #2  
Old 12-19-2017, 06:11 AM
gmayor's Avatar
gmayor gmayor is offline Use a the data from a mail merge field Windows 10 Use a the data from a mail merge field 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

If this is a mail merge then you might be better using -
http://www.gmayor.com/individual_merge_letters.htm.
or
http://www.gmayor.com/MergeAndSplit.htm

either of which will split a mail merge using data from merge field(s) in the document to name the individual letters.

If you are creating single letters using merge data then there are probably better ways to do so than to use mail merge.
__________________
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 12-19-2017, 01:06 PM
macropod's Avatar
macropod macropod is offline Use a the data from a mail merge field Windows 7 64bit Use a the data from a mail merge field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See Send Mailmerge Output to Individual Files in the Mailmerge Tips and Tricks 'Sticky' thread at the top of this forum:
https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 12-19-2017, 02:34 PM
pttsv pttsv is offline Use a the data from a mail merge field Windows 10 Use a the data from a mail merge field Office 2013
Novice
Use a the data from a mail merge field
 
Join Date: Dec 2017
Posts: 2
pttsv is on a distinguished road
Default

Code:
Sub Image_Folder()
'
'
'
'

ImageFolder = _
ActiveDocument.MailMerge.DataSource.DataFields("ImageFolder").Value

FL = Left(ImageFolder, 1)

FName = _
ActiveDocument.MailMerge.DataSource.DataFields("FName").Value

LName = _
ActiveDocument.MailMerge.DataSource.DataFields("LName").Value

File = LName & ", " & FName

NewPath = "Y:\OpenDentImages\" & FL & "\" & ImageFolder & "\"

Dim n As Integer
    Dim FilePath As String
    n = 0
    Do
        FilePath = "Y:\OpenDentImages\" & FL & "\" & ImageFolder & "\" & File & IIf(n = 0, "", n) & ".doc"
        n = n + 1
    Loop Until Dir(FilePath) = ""

ActiveDocument.SaveAs2 FilePath, FileFormat:=wdFormatPDF

ActiveDocument.SaveAs2 FilePath, FileFormat:=wdFormatDocumentDefault



End Sub
this is my code so far.
But it only seems to work on the actual template, but not after the data has been merged. Is it possible to maybe reference the template for the data instead of the ActiveDocument?
Thank you

Last edited by macropod; 12-19-2017 at 02:39 PM. Reason: Added code tags
Reply With Quote
  #5  
Old 12-19-2017, 02:40 PM
macropod's Avatar
macropod macropod is offline Use a the data from a mail merge field Windows 7 64bit Use a the data from a mail merge field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You should study the code in the links you've been given.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail merge how to link mail merge field value to a column heading dsummers Mail Merge 1 05-08-2014 02:59 PM
Mail Merge Empty Data Field Licos101 Mail Merge 2 04-10-2014 06:19 AM
Use a the data from a mail merge field How to ignore a mail merge field if the field is blank redzan Mail Merge 1 05-16-2013 08:34 AM
Merge field source data field kckay Mail Merge 4 03-25-2013 11:06 AM
Use a the data from a mail merge field Mail Merge - If a field is black, take the data from the row below? mikeprent Mail Merge 5 01-05-2012 04:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:02 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