Word macro to save .docm as pdf with specific filename of "surname"&"date"

eyattwop

New Member
Joined
Oct 31, 2012
Messages
2
Hi all,

This is my first venture into a forum so I will try to be detailed and concise! Here's the scenario:

Using Word 2007 I have a mail merged .docm file that includes two macros. The first is an AutoOpen macro that opens the "Find Entry" window, prompting the user to search for one recipient. The second macro sends the letter to the recipient via Outlook and prints the letter (to file the old fashioned way!).

I need to then save the file as a pdf, with the filename of "[Surname] [First Name] [todays date].pdf", which I am currently doing manually. I've tried, without success, to get a macro to input the [Surname] and [First Name] merge fields into the filename in the Save As window. I've also tried bookmarking the fields to reference those in VBA, but I'm now out of my depth!


So there are two things I would love assistance with if possible:

Firstly, solving the auto-filenaming issue to recognise the current entry in the [Surname] and [First Name] merge fields.

Secondly, also having the date in the filename in YY-MM-DD format, to give "[Surname] [First Name] [todays date].pdf" (my letter uses 02 November 2012 format)</SPAN></SPAN>


I'd then like to add this to the end of my macro, which I will include below. Many thanks for taking the time to read this, and even more thanks if you can assist!!


Sub SendAndPrint()
'
' SendAndPrint Macro
' Sends MIT/EXT/ETC email to student email and prints
'
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
End With
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
End With
End Sub
 

eyattwop

New Member
Joined
Oct 31, 2012
Messages
2
Have just realised that posting a MS Word query to MrExcel may have been innapropriate given the name of the site! If so could someone please confirm and I will remove it.

many thanks

Eyattwop
 

Forum statistics

Threads
1,085,724
Messages
5,385,515
Members
401,957
Latest member
Socksnpants

Some videos you may like

This Week's Hot Topics

Top