Restarting the numbering with vba

W

Warrio

Hello!

Is there a possibility to restart the numbering with VBA?

I need to do that because when I insert as a link (always through vba code)
a file that might contain a series of numbering paragraphs, this numbering
continues in the next instance of the file. Is there a way to restart it for
all the numbering series from 1 for each instance of the file?

manually I would right-click on the begining of each series and restart it.

if there was a collection for the ListFormat, that would be more helpful...

Thanks for any advice!
 
S

Shauna Kelly

Hi Warrio

Doing this manually, when a real human being can see what's required is
hard. Doing it in code, where you can't really see what's required is likely
to lead to strange results.

I think the best way to do this is to treat the resulting document as a
throw-away document, that you re-create whenever it's needed. Then, the user
does not need to work on the document you're creating, and therefore does
not need the paragraph numbers to increment when new text is added. If you
can do that, then I would suggest you:
- open the source document and save a temporary copy of it
- close the original source document
- in the temporary copy, use .ConvertNumbersToText to turn the paragraph
numbers into 'hard' numbers
- insert the copy as the source document, but not as a link
- close and delete the temporary copy

Note that .ConvertNumbersToText is a one-way street. Once the numbers are
converted, you can only go back to 'real' paragraph numbering if you
manually delete the hard numbers and re-apply the relevant styles to each
individual paragraph.

If you can't use this method, then you'll have to assume that the numbering
in the document was absolutely 100% consistent, and/or guess at what the
user had intended. The only way to re-start numbering is to get a reference
to the relevant List (or ListFormat) and use the ApplyListTemplate method
with ContinuePreviousList = False.

Under no circumstances use the ListGalleries collection of a ListGallery
object. The ListGalleries are the objects represented in the dialog box at
Format > Bullets and Numbering. They are user-specific and machine-specific.
A bit of trial and error will show you that they change to reflect the most
recently-used bullets or numbering schemes. You can't use them in code,
because the state of the ListGalleries right now is not necessarily the
state of the ListGalleries in 5 minutes' time, or on another machine.

For more information about this, see
http://www.word.mvps.org/FAQs/Numbering/ListRestartFromVBA.htm
and for further background, see
http://www.word.mvps.org/FAQs/Numbering/WordsNumberingExplained.htm


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
W

Warrio

Hi Kelly!

You've saved my life with the ConvertNumbersToText method :¬)
I was going to browse all the document paragraph by paragraph... and do a
lot of mess

thanks a lot for this simple solution!
Best regards!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top