Let me explain:
I made a macro that splits a Word mergefile into seperate files and saves these as individual pdf files.
The Word document is merged from as Excel file with names, addresses and some calculated numbers.
ActiveDocument.SaveAs FileName:="Individual_letter_2015_" & DocNum & ".pdf", FileFormat:= _
wdFormatPDF
With a counter the filename is numbered...1, 2, 3 etc.
Individual_letter_2015_1.pdf etc.
This works perfectly, but I want to identify the file based on the content, so a name (or initials) of the addressed person.
I would like to selected a piece of text from a fixed position in the Word document.
Store that in a variable, say "DocNameID"
And then save like this with DocNameID in stead of DocNum:
ActiveDocument.SaveAs FileName:="Individual_letter_2015_" & DocNameID & ".pdf", FileFormat:= _
wdFormatPDF
Simplest: In the merge I can insert a three letter initial of the person and make that white in the Word document so it is not printed.
Better but probably more difficult: Selected the persons name, add "_" for the spaces (e.g. Jan_van_Amsterdam)... but that is a random number of characters.
Can anyone give a hint of how to VBA select the name and store that in a variable (postion of text fixed on page, Row X, Character 0...end of text)
Thanks!
Next step is to send the letters via a merged Outlook action, with the letters (pdf) as individual attachments.
I found a YouTube on how to do that... but to test that I first need the individually recognisable named pdf's...