View Single Post
 
Old 02-21-2013, 05:09 AM
UniAdmin UniAdmin is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Feb 2013
Posts: 1
UniAdmin is on a distinguished road
Default Sequentially numbering a document

I have been trying to add a sequential numbering macro to a word document so that each time it is opened the document is given a new number. The form in question is to record 'near misses' and it would be helpful to be able to open and print off the form each time it was required to be filled in with the next number.

I have tried the code below:
Code:
Sub AutoNew() FormNumber = System.PrivateProfileString("C:\Settings.Txt", _ "MacroSettings", "Order") If FormNumber = "" Then FormNumber = 1 Else FormNumber = FormNumber + 1 End If System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _ "FormNumber") = FormNumber ActiveDocument.Bookmarks("FormNumber").Range.InsertBefore Format(FormNumber, "00#") ActiveDocument.SaveAs FileName:="path" & Format(FormNumber, "00#") End Sub

But I get an error message at the line beginning 'System. Private' telling me that the _ is not a valid character.

Any help gratefully received

Last edited by macropod; 02-21-2013 at 07:09 PM. Reason: Added code tags & formatting
Reply With Quote