Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
rachgg4 rachgg4 is offline
external usenet poster
 
Posts: 6
Default Sequential Numbering in Word 2003 and Recycling unused numbers

Once again, I am stuck in Macro world which is quickly consuming me It is
though, quite addictive and I am determined to win the fight I'm having with
my PC.
I work for a company which uses network servers so the document needs to be
accessed by different people but not necessarily at the same time. We operate
Windows XP Word 2003.
I am trying to create a document that will open with a sequential number,
but if the document is not used or opened accidentally then the number it has
generated needs to be recycled for auditing purposes. I seem to be able to
get the number to sequentially generate but the recycling of the number has
got me absolutely beat. I cant for the life of me understand how to do it or
what I am doing wrong.
The other people who would be accessing the document are not very computer
literate and therefore I have tried to get the macro to AutoOpen so the
number is generated for them.
I have tried using code that MVP's have provided other users of the forum
with, but when I try incorporating all different macros I just make a big
mess.
I initially tried with an INI file but that got confusing too.
This is what I have so far ...

Sub AutoNew()
Dim Order As String
Dim sView As String

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings",
"CertificateNumber", "Order")

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

System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")
= Order

sView = ActiveWindow.View 'store the current view
With ActiveWindow
.View = wdPrintView 'set the document view to print layout
.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.WholeStory 'select any existing header text
.Delete Unit:=wdCharacter, Count:=1 'and delete it
.Font.Name = "Arial" 'Set the font characteristics
.Font.Bold = True 'of the inserted header
.Font.Italic = False 'if required
.Font.Size = "16"
.ParagraphFormat.Alignment = wdAlignParagraphRight

'Insert the new header
.TypeText Text:="Certificate No: " & Format(Order, "200#")
End With
.View.SeekView = wdSeekMainDocument 'Close the header view
.View = sView 'and restore the initial view

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")


ActiveDocument.SaveAs
FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2
System Isolations" & Format(Order, "200#")

End Sub


Sub AutoOpen()
Dim Order As String
Dim sView As String

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")

'Create one and set the number to 1, otherwise increment the number

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

System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "InvoiceNumber", "Order")
= Order
sView = ActiveWindow.View 'store the current view
With ActiveWindow
.View = wdPrintView 'set the document view to print layout
.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.WholeStory 'select any existing header text
.Delete Unit:=wdCharacter, Count:=1 'and delete it
.Font.Name = "Arial" 'Set the font characteristics
.Font.Bold = True 'of the inserted header
.Font.Italic = False 'if required
.Font.Size = "16"
.ParagraphFormat.Alignment = wdAlignParagraphRight

'Insert the new header
.TypeText Text:="Certificate No: " & Format(Order, "200#")
End With
.View.SeekView = wdSeekMainDocument 'Close the header view
.View = sView 'and restore the initial view

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")


ActiveDocument.SaveAs
FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2
System Isolations" & Format(Order, "200#")
End With
End Sub
'
' AutoOpen Macro
' Macro created 23/01/2010 by Rachel Watson
'

Sub AutoClose() 'Recycles number if document unsaved.'
If ActiveDocument.Name Like "S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations*" Then
If MsgBox("This Certificate has not been saved. Do you want to save
before closing?", vbYesNo, "MacroSettings") = vbYes Then
Application.Dialogs(wdDialogFileSaveAs).Show
Else
If MsgBox("The current number will be recycled.", vbOKCancel,
"Recycle") = vbOK Then
SettingsFile = Options.DefaultFilePath(wdStartupPath) &
"\Settings.ini"
End If
ActiveDocument.Saved = True
ActiveDocument.AttachedTemplate.Saved = True
End If
End If

End Sub
'
' AutoClose Macro
' Macro created 23/01/2010 by Rachel Watson

If there is anyway at all you are able to give me any help or advice it
would be most appreciated.

Many thanks in advance,

rachgg4



  #2   Report Post  
Posted to microsoft.public.word.newusers
rachgg4 rachgg4 is offline
external usenet poster
 
Posts: 6
Default Sequential Numbering in Word 2003 and Recycling unused numbers

Please ignore this post as the question has now been answered in an earlier
post. Thanks

"rachgg4" wrote:

Once again, I am stuck in Macro world which is quickly consuming me It is
though, quite addictive and I am determined to win the fight I'm having with
my PC.
I work for a company which uses network servers so the document needs to be
accessed by different people but not necessarily at the same time. We operate
Windows XP Word 2003.
I am trying to create a document that will open with a sequential number,
but if the document is not used or opened accidentally then the number it has
generated needs to be recycled for auditing purposes. I seem to be able to
get the number to sequentially generate but the recycling of the number has
got me absolutely beat. I cant for the life of me understand how to do it or
what I am doing wrong.
The other people who would be accessing the document are not very computer
literate and therefore I have tried to get the macro to AutoOpen so the
number is generated for them.
I have tried using code that MVP's have provided other users of the forum
with, but when I try incorporating all different macros I just make a big
mess.
I initially tried with an INI file but that got confusing too.
This is what I have so far ...

Sub AutoNew()
Dim Order As String
Dim sView As String

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings",
"CertificateNumber", "Order")

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

System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")
= Order

sView = ActiveWindow.View 'store the current view
With ActiveWindow
.View = wdPrintView 'set the document view to print layout
.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.WholeStory 'select any existing header text
.Delete Unit:=wdCharacter, Count:=1 'and delete it
.Font.Name = "Arial" 'Set the font characteristics
.Font.Bold = True 'of the inserted header
.Font.Italic = False 'if required
.Font.Size = "16"
.ParagraphFormat.Alignment = wdAlignParagraphRight

'Insert the new header
.TypeText Text:="Certificate No: " & Format(Order, "200#")
End With
.View.SeekView = wdSeekMainDocument 'Close the header view
.View = sView 'and restore the initial view

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")


ActiveDocument.SaveAs
FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2
System Isolations" & Format(Order, "200#")

End Sub


Sub AutoOpen()
Dim Order As String
Dim sView As String

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")

'Create one and set the number to 1, otherwise increment the number

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

System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "InvoiceNumber", "Order")
= Order
sView = ActiveWindow.View 'store the current view
With ActiveWindow
.View = wdPrintView 'set the document view to print layout
.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.WholeStory 'select any existing header text
.Delete Unit:=wdCharacter, Count:=1 'and delete it
.Font.Name = "Arial" 'Set the font characteristics
.Font.Bold = True 'of the inserted header
.Font.Italic = False 'if required
.Font.Size = "16"
.ParagraphFormat.Alignment = wdAlignParagraphRight

'Insert the new header
.TypeText Text:="Certificate No: " & Format(Order, "200#")
End With
.View.SeekView = wdSeekMainDocument 'Close the header view
.View = sView 'and restore the initial view

Order =
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")


ActiveDocument.SaveAs
FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2
System Isolations" & Format(Order, "200#")
End With
End Sub
'
' AutoOpen Macro
' Macro created 23/01/2010 by Rachel Watson
'

Sub AutoClose() 'Recycles number if document unsaved.'
If ActiveDocument.Name Like "S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems
Isolations\Drier 2 System Isolations*" Then
If MsgBox("This Certificate has not been saved. Do you want to save
before closing?", vbYesNo, "MacroSettings") = vbYes Then
Application.Dialogs(wdDialogFileSaveAs).Show
Else
If MsgBox("The current number will be recycled.", vbOKCancel,
"Recycle") = vbOK Then
SettingsFile = Options.DefaultFilePath(wdStartupPath) &
"\Settings.ini"
End If
ActiveDocument.Saved = True
ActiveDocument.AttachedTemplate.Saved = True
End If
End If

End Sub
'
' AutoClose Macro
' Macro created 23/01/2010 by Rachel Watson

If there is anyway at all you are able to give me any help or advice it
would be most appreciated.

Many thanks in advance,

rachgg4



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
customizing sequential numbers in Word Meg Microsoft Word Help 4 October 15th 09 06:41 PM
Creating sequential serial numbers in Word 2003 Eric G Microsoft Word Help 5 July 10th 06 04:28 PM
sequential page numbers in word burtperks Microsoft Word Help 0 January 12th 06 09:47 AM
sequential numbering in Word C. Microsoft Word Help 2 September 2nd 05 08:25 PM
raffle ticket numbering, sequential numbers for word doc? Is this. Ken Microsoft Word Help 1 March 7th 05 02:50 PM


All times are GMT +1. The time now is 12:56 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"