PDA

View Full Version : Naming Word document



Jane1
03-29-2015, 09:49 AM
Hi!

I need a macro to run from a template that will name the document in a set way every time, some information (such as company name) will need to be included automatically every time whilst other info such as date, recipient name, senders name and account number will need to be inserted automatically from the document text.

The document would need to be named as follows:

Companyname_SENDERSINITIALANDSURNAME_date_accountnumber_Recipientsurname_fi rstname


The senders full name will be present in the document in full and standard initial cap format but will need to appear in document as just the initial plus surname in caps. The date and account number will be present in the document in correct format, recipient's name will be present in the format of first name followed by surname but will need to be displayed in the document name as surname followed by surname. Is all of this possible (or at least the majority) and any ideas on where to start?

Thanks!

Jane

gmayor
03-29-2015, 11:25 PM
In theory it is all possible, but where exactly is the information coming from? As this is a template, the logical approach is to create a userform that gathers this data and writes it both to the appropriate places in the document using bookmarks or docvariables and to a string to be used as the document name. You will also probably want to ensure that existing files of the same name are not overwritten and that the names etc entered do not include any illegal filename characters.

See http://www.gmayor.com/Userform.htm which covers the basics.