After I enter Ctrl+F9 to enter a field code bracket, I enter the information
in the quotes.
{ Quote { Set ABC { = { ABC } + 1 } }{ SET ABC2 { IF { ABC } > 26 "{ IF { =
MOD({ ABC }, 26) } = 1 "{ = { ABC2 } + 1 }" "{ ABC2 }" }" "{ ABC2 }" } }{ SET
ABC1 { IF ABC1 < 26 "{ = { ABC1 } + 1 }" "1" } }{ If { ABC } < 27 "{ ABC1 \*
ALPHABETIC }" "{ ABC2 \* ALPHABETIC }{ ABC1 \* ALPHABETIC }" } }
then I press Alt+F9 and everything goes away.
So after the Field Code disappears, how do I begin numbering my list?
Can anyone help with this? It's very frustrating when there isn't a
completed example with results either that, or I'm just not getting it.
Thanks
Miguel
Yes, it is a bit of a pain doing that - I've put a file with the fields in
temporarily at
http://tips.pjmsn.me.uk/quick/xlnumber.doc
Hope you'll be able to get it.
--
Peter Jamieson
http://tips.pjmsn.me.uk
"migpics" <mig...@discussions.microsoft.com> wrote in message
news:BD2020F5-2383-4037...@microsoft.com...
Does this code do the numbering automatically?
It generates an A, which is a good start but I don't end up with anything
except for A's.
Thanks for your help and patience.
Miguel
Be sure to update the fields in the correct order, one by one, with F9. At
least that is how I must do it, in order to get it to work in Word 2007.
(Considering how SET fields work, it actually makes some sense, but since
I've never tried this field construct before, I don't know if this is how it
used to work in older versions of Word.)
If you still run into trouble, note that the MOD command in the field code
must use the list separator character, as determined by your operating
system; for English language versions this usually means a comma.
--
Stefan Blom
Microsoft Word MVP
"migpics" wrote in message
news:0A349608-E907-4B18...@microsoft.com...
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.
--
Peter Jamieson
http://tips.pjmsn.me.uk
"migpics" <mig...@discussions.microsoft.com> wrote in message
news:0A349608-E907-4B18...@microsoft.com...
Yes, because SET sets the value of a bookmark the whole process relies on
that fact that when you update /all/ the bookmarks in a document, Word
updates them starting at the beginning. That may sound rather obvious but it
means for example that if you update the fields in /one/ bullet, Word will
start with the values of ABC, ABC1 and ABC2 at the time you do the update
(which are likely to be the values set in the last bullet in the document),
not the values in the previous bullet in the document. The same applies to
any numbering that is not generated completely automatically by Word.
--
Peter Jamieson
http://tips.pjmsn.me.uk
"Stefan Blom" <no....@please.xyz> wrote in message
news:u6L2OO2V...@TK2MSFTNGP06.phx.gbl...
Thanks for confirming this.
And to clarify what I wrote in my previous message: If I update the initial
SET fields first, then it works to select the QUOTE fields and update them
all at once.
"Peter Jamieson" wrote:
> ..
> SU26 Z
> SU27 AA
> SU28 AB
> ..
> ..