![]() |
#1
|
|||
|
|||
![]() I am trying to automatically generate a filename when saving a document template. The format is as follows: Surname Initial - dob - reference number - AT3.doc I want to use the text entered into a table in the document to generate the filename. The AT3 part at the end is always the same. The problem is that employees quite often get it wrong which makes files very difficult to find. |
#2
|
|||
|
|||
![]()
Hi
Yes this can be done relatively easily with a macro. Are these three pieces of information entered in three separate cells on a table or are they part of free text within the document? Once I have this info I will see what I can do for you. Tony(OTPM) |
#3
|
|||
|
|||
![]()
Thank you OTPM.
The text would come from a table. So in the example attached the format would be saved automatically like so: SURNAME INITIAL - D.O.B - App Ref No - AT2.doc DOB format: 01.01.1990 I understand there may be formating issues which could be resolved with entering the data correctly within the table. Is it possible to use an input mask for this or perhaps a dialogue box when you open the file? Many thanks. |
#4
|
|||
|
|||
![]()
Sorry I uploaded the AT2 version instead of the AT3 one but the principle is the same.
|
#5
|
|||
|
|||
![]()
Hi
First of all you cannot use arithmetical operators in a filename. So a format of dd/mm/yyyy cannot be used. In the example I have used dd-mm-yyyy. See template with code embedded herewith. You need to change one line of code to suit your needs as follows: ChDir "D:\Test Folder" Change it to the location you want to save your files to. As for putting a mask in the DoB cell you can do this if you set up an online form. Hope this helps. Good luck. Tony |
#6
|
|||
|
|||
![]()
Great almost there. I've just changed a few things. The dob format would have to be 01.01.1990 so I added .doc the end of RefNo.
My only problem is that these are stored in various directories and saving them to a specific one won't work. Is there any way of opening the 'save as' dialogue with the correct format present? It seems to be saving it in the default save path anyway rather than the ChDir specified path. |
#7
|
|||
|
|||
![]()
Hi
The only issue now is that you cannot have more than one full stop in a filename as Microsoft looks for the first full stop in a filename and then uses wverything after it to determine which application was used to produce the document. Having 4 full stops in the filename will confuse Microsft Word. You will need to choose another separator for the date of birth other than a period or an arithmetic operator. I will look at the other option you are after. Tony |
#8
|
|||
|
|||
![]()
Thanks Tony, I'm sure I can find another separator.
|
#9
|
|||
|
|||
![]()
Hi
Try this version and let me know how you get on. Good luck. Tony |
#10
|
|||
|
|||
![]()
Perfect thank you!!!
|
#11
|
|||
|
|||
![]()
One last question if possible. I have imported the macro to my working document and adjusted the bookmarks. The macro works fine. However, if this document is passed to another user then the macro has disappeared. I know it's something to do with the normal template but how do I get the macro to stick within the document for each user?
|
#12
|
|||
|
|||
![]()
Hi
What you need to do is store the macro in the actual document rather than the template. Then wherever you send the document the macro will work. Hope this helps. Good luck. Tony |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
AquaSabes | Excel | 1 | 09-22-2011 02:29 AM |
![]() |
don madsen | Word | 6 | 09-16-2011 09:02 PM |
Word: The document 'Filename' caused a serious error the last time ... | martincruise | Word | 0 | 02-25-2010 01:47 AM |
Can't save word document in anything but read format | Stuckie | Word | 0 | 01-21-2010 12:46 PM |
Document Get Deleted When We save | dil_09 | Word | 0 | 08-29-2009 09:59 PM |