Okay, I see how the field code works but where does one start entering the
What I suggest you do is add a tab, or full stop (period) then tab, or
whatever you would usually want after the "number", then copy/paste the
entire set of fields and that tab (apart from the { SET ABC 1 } stuff at the
beginning) so that each set of fields starts in a new paragraph. Let's say,
make 5 copies. Then select the lot and press F9. Press Alt-F9 if necessary
to see the results. You should see e.g.
A.
B.
C.
D.
E.
F.
Then add your text after the tab. To add another bullet, you have to insert
another copy of thhose fields, so it is advisable to keep them somewhere
useful, like an autotext or building block (Word 2007)
However, it is probably better to add anything you want after the "number"
inside the Quote field. That way, it's easier to be sure exactly where you
need to start typing your text and less easy to type text into the result of
the field, where it will be destroyed when you next update the field.
Does this code do the numbering automatically?
Not in the sense that Word does numbering automatically. With numbering
created using your own field codes, you always have to update the field
codes by selecting them and re-executing them (typically using F9). But
that's /all/ you should have to do.
There are other approaches to this problem. For example, if you can download
the document temporarily at
http://tips.pjmsn.me.uk/quick/xlnumb2.doc you
can see a method based on Word Document Variables. These are "invisible
values" created by VBA and stored within a Word document. They are a bit
like Document Properties except that there is no standard user interface
that lets the user set them up. Once you have created the document variables
you need, they are just there - you don't need any VBA in the document. You
can create another document with the same variables simply by copying the
document. You insert the values using { DOCVARIABLE } fields. So for example
if you create variables as follows
Name Value
SU1 A
SU2 B
..
..
SU26 Z
SU27 AA
SU28 AB
..
..
etc.
then you can insert your bullets using the following fields:
{ DOCVARIABLE "SU{ SEQ X }" }
If you want another list, you can use a different SEQ sequence name, e.g.
{ DOCVARIABLE "SU{ SEQ Y }" }
or you can reset the "X" sequence to 0 using e.g.
{ SEQ X \R0 }
VBA code (I've listed it in the document body) to (re-)create the necessary
document variables is as follows (this makes two versions - an uppercase
version with variable names SU1, SU2 etc. and a lowercase version with names
SL1, SL2 etc. Again, you can modify this to generate the exact bullet
content you want, e.g.
changing
strUValue = Chr(intLetter2 + 64)
to
strUValue = Chr(intLetter2 + 64) & "." & chr(9)
would add a full stop and tab after the "number".
'--------------------------------
Sub makesequencevariables()
Dim intLetter1 As Integer
Dim intLetter2 As Integer
Dim strUName As String
Dim strUValue As String
Dim strLName As String
Dim strLValue As String
Dim objVariable As Word.Variable
On Error Resume Next
For intLetter1 = 0 To 25
For intLetter2 = 1 To 26
strUValue = Chr(intLetter2 + 64)
strLValue = Chr(intLetter2 + 96)
If intLetter1 > 0 Then
strUValue = Chr(intLetter1 + 64) & strUValue
strLValue = Chr(intLetter1 + 96) & strLValue
End If
strUName = "SU" & Trim(CStr((26 * intLetter1) + intLetter2))
strLName = "SL" & Trim(CStr((26 * intLetter1) + intLetter2))
With ActiveDocument.Variables
.Item(strUName).Delete
.Add Name:=strUName, Value:=strUValue
.Item(strLName).Delete
.Add Name:=strLName, Value:=strLValue
End With
Next
Next
End Sub
'--------------------------------
The following macro removes /all/ the document variables in a document:
'--------------------------------
Sub removeallvariables()
Dim i As Integer
With ActiveDocument.Variables
For i = .Count To 1 Step -1
.Item(i).Delete
Next
End With
End Sub
'--------------------------------
It's also possible to do much the same thing, just using REF fields and
bookmarks.