Numbering documents

B

Barb

I am trying to set up a purchase order template. I need
to include a macro that will cause it to come up with the
next consecutive P.O. number each time the template is
opened. A friend found me some instructions on the
internet but I get an error message when I try to create
the macro and when I try to run it, obviously. Here's
what I have:
Sub autonumber()
Dim MyString, autoNumb
FileToOpen = "c:\windows\autonumberfile.txt"
Open FileToOpen for Input As #1
Input #1, autoNumb
Close #1
ActiveDocument.Bookmarks("autonumb").Select
Selection.InsertAfterText:=autoNumb
autoNumb = autoNumb + 1
Open FileToOpen For Output As #1
Write #1, autoNumb
Close #1
End Sub

I rarely use macros so I have no idea what is wrong with
this one. Maybe it was written for a different Word
version and doesn't work in 2002. I would appreciate any
guidance anyone can give me.

Thanks!
Barb
 
D

Doug Robbins

See the article "Creating sequentially numbered documents (such as
invoices)" at:

http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top