For macro installation and usage instructions, see:
http://www.gmayor.com/installing_macro.htm.
For instructions on adding custom document properties to a document/template, see:
http://office.microsoft.com/en-us/wo...010047524.aspx
As indicated in my previous reply, the macro simply creates a sequential number and adds that to a custom document property. The macro then prompts the user to immediately save the document with that number. If you want anything fancier, you'll have to say exactly what the rules are for how a macro is supposed to work that out.
Depending on what you want to do with the file, with the above approach, you can use a FILENAME field and/or a DOCPROPERTY field in the header/footer to display the reference number in the document.