S
singeredel
The following autorun code worked in Word 2003/Windows XP:
Sub AutoNew()
InvoiceNo = System.PrivateProfileString("C:\Settings-Hannani.txt",
"MacroSettings", "InvoiceNo")
If InvoiceNo = "" Then
InvoiceNo = "1"
Else
InvoiceNo = InvoiceNo + 1
End If
System.PrivateProfileString("C:\Settings-Hannani.txt", "MacroSettings",
"InvoiceNo") = InvoiceNo
ActiveDocument.Bookmarks("InvoiceNo").Range.InsertBefore
Format(InvoiceNo, "00#")
ActiveDocument.SaveAs FileName:="C:\Hannani\Word Files\Invoices\" +
"Hannani Inv 2008-" & Format(InvoiceNo, "00#")
End Sub
I copied everything over to a new computer running Windows Vista and Word
2007 and get the following error:
"Method 'PrivateProfileString' of object 'System' failed"
This is what appears in the referenced Settings-Hannani.txt file:
[MacroSettings]
InvoiceNo=16
It is used to increment an invoice number each time the template is used to
create a new document.
Can you tell why this does not work in Word 2007?
Thanks...
Sub AutoNew()
InvoiceNo = System.PrivateProfileString("C:\Settings-Hannani.txt",
"MacroSettings", "InvoiceNo")
If InvoiceNo = "" Then
InvoiceNo = "1"
Else
InvoiceNo = InvoiceNo + 1
End If
System.PrivateProfileString("C:\Settings-Hannani.txt", "MacroSettings",
"InvoiceNo") = InvoiceNo
ActiveDocument.Bookmarks("InvoiceNo").Range.InsertBefore
Format(InvoiceNo, "00#")
ActiveDocument.SaveAs FileName:="C:\Hannani\Word Files\Invoices\" +
"Hannani Inv 2008-" & Format(InvoiceNo, "00#")
End Sub
I copied everything over to a new computer running Windows Vista and Word
2007 and get the following error:
"Method 'PrivateProfileString' of object 'System' failed"
This is what appears in the referenced Settings-Hannani.txt file:
[MacroSettings]
InvoiceNo=16
It is used to increment an invoice number each time the template is used to
create a new document.
Can you tell why this does not work in Word 2007?
Thanks...