Creating a word template for a customer invoice

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
Im looking to have a word template that has a reference number made up from a customers name, and the date, also i wanted the document when saved to use that reference number as the filename. Can anyone help me accomplish this.. Thanks..
 
Hi Blair,

If you put the following code into an autonew macro in the template, it
should do what you want.

Dim Message, Title, Default, Customer
Message = "Enter the Customer's Name" ' Set prompt.
Title = "Invoice" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
Customer = InputBox(Message, Title, Default)
' Insert the invoice number into the bookmark named "InvoiceNum
ActiveDocument.Bookmarks("InvoiceNum").Range.InsertBefore Customer &
Format(Date, "yyyyMMdd")
' Save the Document with the filename made up of the customer's name and the
date
ActiveDocument.SaveAs Customer & Format(Date, "yyyyMMdd")

The above is pretty basic however, you can do a lot more with a userform -
things like populating a listbox or combobox on the userform with the names
of your customers held in a database, selecting products/services to be
invoiced etc. etc.

See the article “How to create a Userform” at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
Back
Top