How to get the paragraph number from a paragraph

C

CjimO

I've searched the forum for this and only found code that counted paragraphs...

I have a Range which contains a paragraph. I want to determine if the
paragraph has numbering (1.2, etc.), and if so, how to convert that numbering
into a text string.

TIA
 
H

Helmut Weber

Hi,

MsgBox Selection.Range.ListFormat.ListType
Selection.Range.ListFormat.ConvertNumbersToText

though you probabaly don't need to check,
whether there is numbering at all,
as .ListFormat.ConvertNumbersToText
just doesn't do anything, if there is no number.
 
C

CjimO

I need to clarify ... I don't want to convert the number into text in place,
the text string is a variable. I can get the paragraph without problem:

Range.Paragraphs(1).Range.Copy ' Now in the clipboard

However, after pasting it....

DestRange.Paste

The paragraph number as updated itself, of course and I've lost the original
value. I've though of pasting the paragraph back into the original location,
creating two such paragraphs, converting the *first* to text (to get the real
paragraph number), and cutting that text out, leaving the pasted paragraph
with the correct number. However, not just being a kludge, it would screw up
the change tracking, which must be left on.

What I need is something like:

str = Range.Paragraphs(1).ListFormat.GetNumberAsString

which would leave the original paragraph alone and just return a string
representation of that number.
 
H

Helmut Weber

Hi CjimO,

maybe "liststring", like

MsgBox Selection.Paragraphs(1).Range.ListFormat.ListString

--

Gruß

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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