Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to: restart list number items by writing macros

1,248 views
Skip to first unread message

Tony Dai

unread,
Apr 20, 2003, 11:11:31 PM4/20/03
to
Hi Friends,
I've translated an Eng documnet into Chinese by using Trados. After clearing
up, the list -number items went out of rage.
They looks like the followings:

===================================
In order to do thing 1:
1. bla bla bla
2. ble ble ble
3. blo blo blo

In order to do thing 2:
4. bla bla bla
5. ble ble ble
6. blo blo blo

In order to do thing 3:
7. bla bla bla
8. ble ble ble
9. blo blo blo
==================================

But actually they should look like:

=================================
In order to do thing 1:
1. bla bla bla
2. ble ble ble
3. blo blo blo

In order to do thing 2:
1. bla bla bla
2. ble ble ble
3. blo blo blo

In order to do thing 3:
1. bla bla bla
2. ble ble ble
3. blo blo blo
=====================================

In other words, the list should have restarted but they did not.
Could anybody let me know how I fix this problem by writng piece of
VBA codes? Oh yes, all the listed items have a style 'list number'
in my document.

Thanks in advance,
Tony


Margaret Aldis

unread,
Apr 21, 2003, 6:51:25 AM4/21/03
to
Hi Tony

If your 'In order to' paragraphs all use the same style (say, Body Text)
then the best way to automate this is probably to redefine your
numbering so that the number on List Number restarts after a Body Text
paragraph. Better still would be if these lists each occur with their
own section (Thing 1, Thing 2 etc.) - in that case you can use the
heading hierarchy to pull the same trick.

For information about setting up outline numbering schemes see Shauna
Kelly's instructions at:

http://www.ShaunaKelly.com/word/numbering/OutlineNumbering.html

If you can't use this an existing style to force the restart, then you
have two other possibilities:

You can introduce a dummy style (formatted small and white so as not to
interfere with the print) to do the same job, and add a paragraph in
that style before each list.

You can use VBA to restart numbering on the first item in the list.
Steve Hudson's code for this is:

Public Sub RestartListNumbering()
'her...@tdfa.com
Dim TheRange As Range
Set TheRange = Selection.Range
TheRange.Collapse
On Error Resume Next
With TheRange.ListFormat
.ApplyListTemplate .ListTemplate, False
End With
End Sub

The disadvantage of this over the style method is that you are applying
direct formatting to the paragraph, so if you reset to style at some
point in the future the numbering will (quite correctly) return to
continuous.

However, your main challenge in either case is likely to be identifying
the first list item programmatically.

Hope this helps

Margaret

In article <#vpvfP7B...@TK2MSFTNGP11.phx.gbl>, Tony Dai
<asia...@sina.com> writes

--

Margaret Aldis, Syntagma, e-mail Margare...@syntagma.co.uk

"Civilisation advances by extending the number of important
operations which we can perform without thinking about them.
Operations of thought are like cavalry charges in battle - they are
strictly limited in number, they require fresh horses, and must
only be made at decisive moments." A N Whitehead

Suzanne S. Barnhill

unread,
Apr 21, 2003, 8:57:51 AM4/21/03
to
An easier way is to set up an outline-numbered list with the "In order to
do" paragraph as Level 1. It doesn't have to be numbered; you can set the
numbering to "(none)." Then make List Number Level 2 and set it to restart
after Level 1. For instructions on how to set up an outline-numbered list so
it won't break, see
http://www.shaunakelly.com/word/numbering/OutlineNumbering.html.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Tony Dai" <asia...@sina.com> wrote in message
news:#vpvfP7B...@TK2MSFTNGP11.phx.gbl...

Margaret Aldis

unread,
Apr 21, 2003, 10:17:34 AM4/21/03
to
Apologies if it wasn't clear - that was indeed what I was recommending
as my first option - but it does depend on the assumption that you
already have a paragraph of the chosen 'level 1' style before the start
of every list.

Margaret

In article <eVVISeAC...@TK2MSFTNGP11.phx.gbl>, Suzanne S. Barnhill
<sbar...@mvps.org> writes

--

Suzanne S. Barnhill

unread,
Apr 21, 2003, 5:52:42 PM4/21/03
to
If you'll note, my response was not to your post but to Tony's original
post. I had not seen yours till now (looks like the Communities are not the
only place your posts are showing up slowly or not at all).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Margaret Aldis" <margare...@nospam.demon.co.uk> wrote in message
news:fI6dhiK+1$o+I...@syntagma.demon.co.uk...

Word Heretic

unread,
Apr 22, 2003, 2:57:40 AM4/22/03
to
G'day "Tony Dai" <asia...@sina.com>,

I'd probably select the entire document and convert all the numbering
to manually formatting (raw text). You do this by VBE (Alt+F11) >
Immediate Window (Ctrl+G) > ActiveDocument.ConvertNumbersToText

Then translate. Then modify this routine,an excerpt from my Word VBA
Spellbook, below as needed:


Convert manual formatting to styles
============================

Public Sub ConvertHardCoded2Styles()
Const NumberStyle As String = "List Number"
Const BulletStyle As String = "List Bullet"
Dim CharPos As Long
Dim Para As Paragraph
Dim BulletChars As String
Dim s As String

BulletChars = "." & "*" & "-" & Chr$(176) & ChrW$(61623) &
ChrW$(61607) & ChrW$(61608) _
& ChrW$(61609) & ChrW$(61610) & ChrW$(61528) & ChrW$(61529) &
ChrW$(61556) & _
ChrW$(61557) & ChrW$(61558) & ChrW$(61559) & ChrW$(61562) & _
ChrW$(8224) & ChrW$(8225) & ChrW$(9679)

With ActiveDocument
For Each Para In .Paragraphs
With Para
s = Mid$(.Range.Text, 1, 1)
If StrConv(s, vbUnicode) = Format(Val(s)) Then 'number!
.Style = NumberStyle
StripStartOfPara Para
ElseIf InStr(1, BulletChars, s) Then
.Style = BulletStyle
StripStartOfPara Para
End If
End With
Next
End With

Set Para = Nothing
End Sub


"Tony Dai" <asia...@sina.com> was spinning this yarn:

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email: word_h...@yahoo.com.au
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 1129 pages of dump left and dropping...

The VBA Beginner's Spellbook: For all VBA users.

Margaret Aldis

unread,
Apr 22, 2003, 5:36:52 AM4/22/03
to
Ah yes - I was fooled when reading by the order the messages flowed on
my news reader and the 'easier' in your reply. Thought I must have
goofed in the way I explained it.

Probably just a timing thing as my posts go via usenet dissemination -
the Web access still seems to be a separate problem.

Margaret

In article <#X5RqGFCD...@TK2MSFTNGP10.phx.gbl>, Suzanne S. Barnhill

Suzanne S. Barnhill

unread,
Apr 22, 2003, 8:49:40 AM4/22/03
to
Is there some reason you're not connecting directly to msnews? I realize
this does require a separate news account, which may be more trouble than
it's worth if you subscribe to many Usenet NGs. Since I subscribe only to MS
NGs, it is not an issue for me. Even when I did read other Usenet groups, it
was no trouble to switch from one server (news account) to another using
Outlook Express, but I see you're using a different newsreader, so it may be
more difficult for you.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Margaret Aldis" <margare...@nospam.demon.co.uk> wrote in message

news:RFZOSeC0...@syntagma.demon.co.uk...

Margaret Aldis

unread,
Apr 22, 2003, 10:22:03 AM4/22/03
to
Answered off-group

In article <u8VDz5MC...@TK2MSFTNGP10.phx.gbl>, Suzanne S. Barnhill

0 new messages