Get numbering text when several ListNum on same line

T

Tiago

Hi,

I'm having trouble getting the numbering text of a ListNum field when
it is not the first numbering field in a paragraph.
I usually use the ListFormat.ListString property, but it doesn't work
in this case, as this property (and ListFormat in general) always gets
the first list entity in a paragraph.
So if I had this in the document:
"It happens fbecause: a) reason1, b) reason 2, c) reason 3"
the ListFormat.ListString for any range in this line (including the
listnum "Result" and "Code" ranges for any listnum field) would be
"a)".
The same happens if I have a listnum field after a bullet (don't ask me
why anyone would this, it's not my document :)), the code character for
the bullet is returned (whatever it is).

So, how can I get the resulting text of a listnum field, or the listnum
field immediately before the current selection (I have no trouble
finding the field, just getting the text)?

Hope you can help
Thanks
 
H

Helmut Weber

Hi Tiago,

I doubt, whether several listnumbers can be in one line,
not even in the same paragraph.

It seems, all readers here are puzzled about that.

You may send me a sample doc, if you can.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tiago

Hi again,

It seems to be possible, my client's files are full of them...
Even if it was not the case, the bullet/ListNum combination produces
the same result, where ListFormat.ListString return the text from the
first numbering field/item in the paragraph, in this case, the bullet.

I've sent you an example file by mail, which I've created myself
(Word97), hope you can take a look at it soon.

Cheers
 
H

Helmut Weber

Hi Tiago,
I've sent you an example file by mail, which I've created myself
(Word97), hope you can take a look at it soon.

I can't see that I got a mail from you.

Did you translate the mail-address below correctly?

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de" <<<
 
T

Tony Jollans

This looks like a bug to me.

I have replied to your identical post in the numbering newsgroup. It is
better for all concerned if you don't multi-post.
 
H

Helmut Weber

Hi Tiago,

got your doc now.

Only wierd approaches possible, I think.

Maybe like this, for not bulleted paragraphs!

Sub Myfields()
Dim oFld As Field
Dim sTmp As String
Dim lCnt As Long
With Selection.Paragraphs(1).Range
sTmp = .ListFormat.ListString
For Each oFld In .Fields
If oFld.Type = wdFieldListNum Then
lCnt = lCnt + 1
If lCnt > 1 Then
MsgBox chr(Asc(Left(sTmp, 1)) + 1) & Right(sTmp, 1)
' certainly somewhat limited
End If
End If
Next
End With
End Sub


For bulleted paragraphs, if I select the first field
of type wdFieldListNum in that paragraph and copy it
to the clipboard, I see "a)" in the clipboard.

From then on, it's doable, IMHO.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Helmut Weber

Hi
MsgBox chr(Asc(Left(sTmp, 1)) + 1) & Right(sTmp, 1)

which is only an example for the first "b)" after "a)".

You have to use the counter lCnt
to get "c)", "d)", etc.

HW
 
T

Tony Jollans

Very clever, Helmut.

The clipboard is interesting. The Office clipboard shows a) b) c) etc for
the entries but pasting them (via the dropdown in the Task Pane) pastes
another LISTNUM - so "d)" perhaps. The Windows clipboard shows "1)" no
matter which number is copied - and Paste Special > Unformatted Text pastes
"1)".
 
H

Helmut Weber

Hi Tony,

as long as the clipboard shows "1)" or "a)" it's alright.
One could then calculate the following not accessible
field results.

So far, I've not found a methode for retrieving
what's in the office clipboard.
Not to speak of other numbering schemata, like roman.

But that's theory.

Have a nice day.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tiago

Thank you all for your help.
I'd already though of this counting approach, but really thought there
ought to be a better way!
Seems not, though...
Since I never know what kind of numbering scheme the document as
(numerals, letters, roman, etc.) it's going to be a pain to account for
all "regular" cases).
But, if that's the way to go... So be it!

Cheers
 

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