From: nerfemail on
Hi,

I need your help. I spent many hours and have not found a solution for
my problem.
I have a big word 2003 document. It has many headings (up to 5+ levels
deep). It also has bullets (lists).

I found a piece of code, that lets me place all the headings in a
listbox, but I don't know how to select the current (cursor) heading
in the listbox.

I tried to get the current heading text, but some heading titles
contain the same text.

Is it possible to get the heading ID? So that I can use
listbox1.listindex=HeadingID? Can you help?

Thank you


POPULATING THE LISTBOX:
varRefType = WdReferenceType.wdRefTypeHeading
varXRefs =
ActiveDocument.GetCrossReferenceItems(ReferenceType:=varRefType)
For Index = 1 To UBound(varXRefs)
Me.ListBox1.AddItem varXRefs(Index)
Next Index

DOCUMENT:

1 HEADING ONE TITLE
- bullet list
1.1 HEADING TITLE
* mouse cursor is here (should select this entry when adding to
listbox)
2 HEADING TITLE
etc.


From: Doug Robbins - Word MVP on
With Selection.Paragraphs(1).Range
MsgBox .ListFormat.ListString & " " & .Text
End With

Displays the number applied to the heading and its text

So you will probably need to load your listbox with the

..Range.ListFormat.ListString & " " & .Text

of each heading so that you can then identify the item in the listbox that
matches the heading in which the cursor is located.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"nerfemail" <nerfemail(a)gmail.com> wrote in message
news:d7294c21-38c2-46f6-b849-6febff8f6845(a)40g2000vbr.googlegroups.com...
> Hi,
>
> I need your help. I spent many hours and have not found a solution for
> my problem.
> I have a big word 2003 document. It has many headings (up to 5+ levels
> deep). It also has bullets (lists).
>
> I found a piece of code, that lets me place all the headings in a
> listbox, but I don't know how to select the current (cursor) heading
> in the listbox.
>
> I tried to get the current heading text, but some heading titles
> contain the same text.
>
> Is it possible to get the heading ID? So that I can use
> listbox1.listindex=HeadingID? Can you help?
>
> Thank you
>
>
> POPULATING THE LISTBOX:
> varRefType = WdReferenceType.wdRefTypeHeading
> varXRefs =
> ActiveDocument.GetCrossReferenceItems(ReferenceType:=varRefType)
> For Index = 1 To UBound(varXRefs)
> Me.ListBox1.AddItem varXRefs(Index)
> Next Index
>
> DOCUMENT:
>
> 1 HEADING ONE TITLE
> - bullet list
> 1.1 HEADING TITLE
> * mouse cursor is here (should select this entry when adding to
> listbox)
> 2 HEADING TITLE
> etc.
>
>
From: nerfemail on
On May 29, 6:00 pm, "Doug Robbins - Word MVP"
<d...(a)REMOVECAPSmvps.org> wrote:
> With Selection.Paragraphs(1).Range
>      MsgBox .ListFormat.ListString & "  " & .Text
> End With
>
> Displays the number applied to the heading and its text
>
> So you will probably need to load your listbox with the
>
> .Range.ListFormat.ListString & " " & .Text
>
> of each heading so that you can then identify the item in the listbox that
> matches the heading in which the cursor is located.
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>
> "nerfemail" <nerfem...(a)gmail.com> wrote in message
>
> news:d7294c21-38c2-46f6-b849-6febff8f6845(a)40g2000vbr.googlegroups.com...
>
> > Hi,
>
> > I need your help. I spent many hours and have not found a solution for
> > my problem.
> > I have a big word 2003 document. It has many headings (up to 5+ levels
> > deep). It also has bullets (lists).
>
> > I found a piece of code, that lets me place all the headings in a
> > listbox, but I don't know how to select the current (cursor) heading
> > in the listbox.
>
> > I tried to get the current heading text, but some heading titles
> > contain the same text.
>
> > Is it possible to get the heading ID?  So that I can use
> > listbox1.listindex=HeadingID? Can you help?
>
> > Thank you
>
> > POPULATING THE LISTBOX:
> > varRefType = WdReferenceType.wdRefTypeHeading
> >    varXRefs =
> > ActiveDocument.GetCrossReferenceItems(ReferenceType:=varRefType)
> >    For Index = 1 To UBound(varXRefs)
> >       Me.ListBox1.AddItem varXRefs(Index)
> >    Next Index
>
> > DOCUMENT:
>
> > 1 HEADING ONE TITLE
> > - bullet list
> > 1.1 HEADING TITLE
> >   * mouse cursor is here (should select this entry when adding to
> > listbox)
> > 2 HEADING TITLE
> > etc.

Thanks Doug, but I had tried that. If the cursor is over a bullet
list, it returns "?" followed by the bullet text.

I found another way; very messy. I get the entire text from the
current heading and then parse it to get the heading title...


From: Doug Robbins - Word MVP on
Your post only asked about getting the current heading, not an item in a
bulleted list.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"nerfemail" <nerfemail(a)gmail.com> wrote in message
news:c6a8d7ca-de44-4651-a244-f96572a03d1a(a)11g2000prv.googlegroups.com...
> On May 29, 6:00 pm, "Doug Robbins - Word MVP"
> <d...(a)REMOVECAPSmvps.org> wrote:
>> With Selection.Paragraphs(1).Range
>> MsgBox .ListFormat.ListString & " " & .Text
>> End With
>>
>> Displays the number applied to the heading and its text
>>
>> So you will probably need to load your listbox with the
>>
>> .Range.ListFormat.ListString & " " & .Text
>>
>> of each heading so that you can then identify the item in the listbox
>> that
>> matches the heading in which the cursor is located.
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>>
>> "nerfemail" <nerfem...(a)gmail.com> wrote in message
>>
>> news:d7294c21-38c2-46f6-b849-6febff8f6845(a)40g2000vbr.googlegroups.com...
>>
>> > Hi,
>>
>> > I need your help. I spent many hours and have not found a solution for
>> > my problem.
>> > I have a big word 2003 document. It has many headings (up to 5+ levels
>> > deep). It also has bullets (lists).
>>
>> > I found a piece of code, that lets me place all the headings in a
>> > listbox, but I don't know how to select the current (cursor) heading
>> > in the listbox.
>>
>> > I tried to get the current heading text, but some heading titles
>> > contain the same text.
>>
>> > Is it possible to get the heading ID? So that I can use
>> > listbox1.listindex=HeadingID? Can you help?
>>
>> > Thank you
>>
>> > POPULATING THE LISTBOX:
>> > varRefType = WdReferenceType.wdRefTypeHeading
>> > varXRefs =
>> > ActiveDocument.GetCrossReferenceItems(ReferenceType:=varRefType)
>> > For Index = 1 To UBound(varXRefs)
>> > Me.ListBox1.AddItem varXRefs(Index)
>> > Next Index
>>
>> > DOCUMENT:
>>
>> > 1 HEADING ONE TITLE
>> > - bullet list
>> > 1.1 HEADING TITLE
>> > * mouse cursor is here (should select this entry when adding to
>> > listbox)
>> > 2 HEADING TITLE
>> > etc.
>
> Thanks Doug, but I had tried that. If the cursor is over a bullet
> list, it returns "?" followed by the bullet text.
>
> I found another way; very messy. I get the entire text from the
> current heading and then parse it to get the heading title...
>
>