Purchase Order Template Question

P

Patty

I created a PO with an "AutoNew" number bookmarked.
Please look at my formula and tell my why this doesn't advance to the next
sequential number when I open the template as "New".
***I wanted to start the numbering at 17999 so the next NEW one opened would
be 18000...etc.***


Sub AutoNew()
Order = System.PrivateProfileString("C:\Settings.Txt", "MacroSettings",
"Order")
If Order = "" Then
Order = 17999
Else
Order = Order + 1
End If
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", "Order") =
Order
ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "17999")
ActiveDocument.SaveAs FileName:="Purchase Order" & Format(Order, "17999")

' AutoNew Macro
' Macro recorded 1/26/2007 by Patricia Richardson
'

End Sub
 
E

Ed

Hi Patty,

If only one person is going to use the Settings.txt file, you could set the
Order number in the file to be 17999 and then in your code replace the "If ..
Then .. Else .. End If" block with just "Order=Order + 1".

If several people are going to use the file and the Order number in the file
may be blank (or the file not exist initially) then in your code leave the
"If .. Then .. Else .. End If" block and change "Order = 17999" to "Order =
18000"

Also, the "Format" lines in the code need a little alteration. The first
value in the Format function is the thing that you want to format and the
second value is a "picture" of how you want it to be formatted.

If you want the order numbers to display with leading zeroes then change the
Format functions to "Format(Order, "00000")".

If you want the order numbers to display without leading zeroes then change
the Format functions to "Format(Order, "#####")".

Cheers.

Ed
 

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