Problem using VBA to create sequentially numbered documents in Word

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,
I am using a certain Autonew VBA program to automatically generate a new
invoice number every time a certain word document is opened. Everytime I use
it, it works great UNLESS I switch users on my computer, it which case I get
the error message "Method 'PrivateProfileString' of object 'System' failed"
Any help is greatly appreciated. Here is the code, which was borrowed from
Doug Robbin's article "Creating sequentially numbered documents (such as
invoices)" from Microsoft MVP.
thanks again,

Steve

Private Sub Document_Open()

Order = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "Order")

If Order = "" Then
Order = 1
Else
Order = Order + 1
End If

System.PrivateProfileString("C:\Settings.Txt", "MacroSettings", _
"Order") = Order

ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "00#")
ActiveDocument.SaveAs FileName:="order" & Format(Order, "#")

End Sub
.



Relevant Pages

  • Re: why Isnt any of the experts helping me?
    ... A1 Invoice Number ... Public ArrayNumber As Integer ... In the userform you want 4 text boxes (for ... Private Sub CompanyNamesCB_Change ...
    (microsoft.public.excel.misc)
  • Re: why Isnt any of the experts helping me?
    ... A1 Invoice Number ... Public ArrayNumber As Integer ... In the userform you want 4 text boxes (for ... Private Sub CompanyNamesCB_Change ...
    (microsoft.public.excel.misc)
  • Re: why Isnt any of the experts helping me?
    ... A1 Invoice Number ... Public ArrayNumber As Integer ... In the userform you want 4 text boxes (for ... Private Sub CompanyNamesCB_Change ...
    (microsoft.public.excel.misc)
  • RE: Auto Number in Invoice
    ... Semi-Automatic version - double-click in a specific cell to get a new invoice ... Private Sub Workbook_SheetBeforeDoubleClick(_ ... StartingNumber = Abs)) ... Two slightly different versions of the same invoice workbook. ...
    (microsoft.public.excel.newusers)
  • Re: Count unique numbers multiple criteria
    ... I have a lot of invoice numbers that I need to count. ... associated with a Purchase order number (in some cases multiple ... Dim UniqueInvoice As Long ... Private Sub ChangeDB() ...
    (microsoft.public.excel.programming)