Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / General MS Word Questions / January 2008

Tip: Looking for answers? Try searching our database.

Automatic "non-sequential" numbering in a requirements specification?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vince.public@gmail.com - 28 Jan 2008 22:33 GMT
I'm trying to create a Word template for a requirements specification,
but I'm going nuts trying to figure out if I can cajole/beg/strong-arm
Word into handling something for me...

Let's say I define a style to be used for formatting a requirement
(call it "Requirement"... duh). Now in the simplest use of this style,
I could have a multiple paragraphs tagged with this style and can get
them to automatically be numbered in sequential order, e.g.:

   REQ-1: blah blah blah
   REQ-2: blah blah blah

   (some filler text)

   REQ-3: blah blah blah

   (more filler text)

   (etc.)

Now let's say I need to insert a new Requirement instance between the
existing REQ-1 and REQ-2 above. When I do this now, the new instance
becomes REQ-2; the old REQ-2 becomes REQ-3, the old REQ-3 becomes
REQ-4, etc. What I would *like* to do instead is have this new
instance be automatically numbered as REQ-4 (or whatever the next
highest "available" value is for this style).

Similarly, let's say that I delete REQ-3 above and add a new
Requirement instance somewhere. That new instance now becomes REQ-3,
but I'd *like* to have it be auto-numbered as REQ-4 (or whatever the
next highest "available value is for this style).

Can either/both of these behaviors be affected via... I don't know
what -- macros? clever use of [custom?] fields? magic?

Thanks,
- Vince
askteam.mail@gmail.com - 29 Jan 2008 00:15 GMT
I've done requirement in MS word before. Let understand the concept of
template first
before solving your numbering issue,

http://www.soi12.com/office/story.php?title=Understand_powerful_under-utilized_c
apacity_of_template-Dot


http://www.soi12.com/office/story.php?title=More_choices_for_numbered_headings_o
r_outline_numbering

Stefan Blom - 29 Jan 2008 09:32 GMT
Something like this could be used:

Const CustomPath$ = "H:\settings.txt"
Sub InsertNumber()

'This is a modified version of the macro at
'http://word.mvps.org/faqs/macrosvba/NumberDocs.htm
'(by Doug Robbins)

Dim Order As String

Order = System.PrivateProfileString(CustomPath, _
       "MacroSettings", "Order")

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

System.PrivateProfileString(CustomPath, "MacroSettings", _
       "Order") = Order

Selection.InsertAfter "REQ-" & Order
Selection.Collapse wdCollapseEnd

End Sub

Note 1: The "current" number is stored in a text file (settings.txt). I used
"H:\settings.txt" as the full path for the text file. You should specify a
path that is relevant on your system.

Note 2: If you want to change the number set by the macro, for example when
you are creating a new document, just edit the number in the settings.txt
file.

Note 3: If you need installation instructions, see
http://www.gmayor.com/installing_macro.htm.

Signature

Stefan Blom
Microsoft Word MVP

> I'm trying to create a Word template for a requirements specification,
> but I'm going nuts trying to figure out if I can cajole/beg/strong-arm
[quoted text clipped - 33 lines]
> Thanks,
> - Vince
Stefan Blom - 29 Jan 2008 10:56 GMT
If numbering should be document-specific, you can make use of these macros
instead (place them in the attached template):

Sub InsertNumberInDoc()
Dim v As Variable
If VarExists("test") = False Then
ActiveDocument.Variables.Add "test", 0
End If

Set v = ActiveDocument.Variables("test")

If IsNumeric(v.Value) And v.Value >= 0 Then
   v.Value = v.Value + 1
Else
   v.Value = 1
End If

Selection.InsertAfter "REQ-" & v.Value
Selection.Collapse wdCollapseEnd

End Sub

Function VarExists(VarName As String) As Boolean
Dim v As Variable
For Each v In ActiveDocument.Variables
   If v.Name = VarName Then
       VarExists = True
       Exit Function
   End If
Next v
End Function

Attach the InsertNumberInDoc sub-routine to a toolbar button (Word 97-2003)
or add it to the Quick Access Toolbar (Word 2007). Also, you can assign a
keyboard shortcut.

See also http://www.gmayor.com/installing_macro.htm.

Signature

Stefan Blom
Microsoft Word MVP

> Something like this could be used:
>
[quoted text clipped - 74 lines]
>> Thanks,
>> - Vince
vince.public@gmail.com - 29 Jan 2008 15:58 GMT
@askteam: My work is already being done in the context of templates,
but those were still a couple of useful links -- thanks!

@Stefan: Thanks for the detailed info! I'll definitely give those
(probably the 2nd option) a go.

- Vince
Stefan Blom - 30 Jan 2008 08:30 GMT
Thank you for the feedback.

Please post back if you run into trouble.

Signature

Stefan Blom
Microsoft Word MVP

> @askteam: My work is already being done in the context of templates,
> but those were still a couple of useful links -- thanks!
[quoted text clipped - 3 lines]
>
> - Vince
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.