Hi All,
I'm trying to put together a simple bit of code that cycles through my mail merge, and prints to PDF using a merge field value as a file name. The code i've got at the minute is as follows:
I'm normally fairly competant in excel with this sort of thing but word is a new ball game for me so any help would be much appreciatedSub letter() ' Dim ghName As String ghName = ** This is where I want to use a merge field ** Do ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord ActiveDocument.PrintOut ** This is where I want to set the documents name to the merge field value & "letter"** Loop End Sub
Hi,
Not sure how much help I'll be as like you Word isn't my thing but I'll try.
What software are you using to create the pdf?
Dom
PS I may get told off for promoting a competitor but I know MacroPod (Word MVP) hangs around at Mr Excel sometimes and has helped me in the past.
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
Hi Dom,
I'm using an adobe driver I think? It's set up as a printer, and you click print to pdf!
You need to have Adobe Acrobat Professional if you want to control it with vba as far as specifying file names etc
There's a link to some code I wrote here along with one that uses some alternative free pdf software:
http://www.excelforum.com/excel-prog...be-writer.html
It's all Excel oriented but theory should be the same if working with Word.
Of course if you have access to Office 2007/2010 then pdf printing is built in.
Dom
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
Thanks for that dom.
The pdf driver definitely works as i've used it with excel vba. The syntax for word doesn't appear to be the same though![]()
The driver itself is basically a printer driver so you can control it via vba as far as printing like your code showed but to do anything else you would need the pro version which allows you to set references to the distiller and control the file name etc. You might want to check out Planet PDF as well.
Dom
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks