Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serial numbering invoices 1

Status
Not open for further replies.

Beorn

Technical User
Mar 17, 2003
2
US
How do I create a unique serial number using the current date everytime a template is opened? Then when the template is edited, I need this number to remain fixed and not change if that file is opened at a later date.

Thanks
 
If I understand you correctly, the following macro should work. It will auto-execute when the file is opened (as long as the auto-execute option has not been deselected):


name 37697922


\0 {BREAKOFF}
{LET name;@string(@now*1000;0)}
{RANGE-NAME-DELETE "\0"}
{FILE-SAVE +NAME&".WK4";;;"replace"}


The template will be unchanged. Use for .123 format for versions 9.x (and I think you can forget the BREAKOFF line in that case too.)

In order to work backwards from the filename to the date, use:

@VALUE(NAME)/1000 in a cell with a date format.
The time can also be extracted within a fair degree of precision using a similar precision.
 
Can this be done without a macro? Just using @ functions?
 
No. Code "Just using @ functions" would change every time the cell was re-calced, intentionally or otherwise. This truly clever macro exec's just once... at the instant when the template is opened. Then it's code ceases to exist as a macro in any derivative worksheet, which is auto pre-named (protecting the template from inadvertent overwriting).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top