I
Irshad Alam
This is in reference to the earlier posted Question and Answer related to
same topic, based on that I tried to do and failed.
I visited the below site, copied the codes, Open a new document create a
form type document and inserted Bookmark and a Macro named "AutoNew" and
pasted the code. Save the document as a Template.
http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm
When I open the template file, first time it works fine, It puts the first
number as 001 and save the file as Path001.
But when I open the document second time onwards, it produces the same
number (001) instead of 002 onwards.
I dont know where is the mistake I am doing. The code I have pasted is as
follows :
Sub AutoNew()
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:="path" & Format(Order, "00#")
End Sub
I am using this on Windows XP operating system and MS office 2000.
Please advise me.
Regards.
Irshad Alam
Abu Dhabi -UAE
same topic, based on that I tried to do and failed.
I visited the below site, copied the codes, Open a new document create a
form type document and inserted Bookmark and a Macro named "AutoNew" and
pasted the code. Save the document as a Template.
http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm
When I open the template file, first time it works fine, It puts the first
number as 001 and save the file as Path001.
But when I open the document second time onwards, it produces the same
number (001) instead of 002 onwards.
I dont know where is the mistake I am doing. The code I have pasted is as
follows :
Sub AutoNew()
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:="path" & Format(Order, "00#")
End Sub
I am using this on Windows XP operating system and MS office 2000.
Please advise me.
Regards.
Irshad Alam
Abu Dhabi -UAE