! Merge field to be used as variable !

W

Wembly

Hi,

I'm setting up a letter merge in Word and is being done
via VBA.

I want to be able to automatically save a file using a
particular field from the merged letter (a merged field).
E.g. when the user clicks on the save button, it saves it
using a concatenated string of two other variables namely
today's date and letter reference number (which also
appears on the merged letter).

Your help is greatly appreciated.

Wembly
 
P

Peter Jamieson

If the merge is only ever producing one document, from one record in the
data source, /and/ you are already using VBA to perform the merge, then you
ought to be able to construct the name from e.g.

'----------------------
Dim strOutputDocumentName As String
' substitute the date format string you need, and the field name
' containing the letter reference
strOutputDocumentName = format(date,"YYYY.MM.DD") & _
" " & _
..DataSource.Datafields("LetterRef").Value & _
".doc"

' Do the merge at some point, then...

' The Activedocument is always the output document
ActiveDocument.SaveAs strOutputDocumentName

'----------------------

if what you are doing is more complicated than that, let us know how.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top