Solved

VBA: How to tell if Number of an outline numbered style is selected?

Posted on 2014-04-19
3
509 Views
Last Modified: 2014-04-20
Hi All,

This is bugging me - I'm sure there is a way but I think I ate too much chocolate this morning and can't think straight...

I have an outline numbered style set (setup as per Shauna Kelly's recommendations) and I would like to know if the number is selected... see below:

1    Text
[2]  Text
3    Text

How do I check if a selection is the paragraph number?
selection.range. ???

Open in new window


TIA

& Happy Easter :-)
0
Comment
Question by:DrTribos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 40011006
I don't know that there is a simple test but irrespective the following tests for a numbered paragraph and for the cursor range limited to the start of the paragraph then the following function ought to do it:

Function testRangeisNumberedParagraph(rng As Range) As Boolean
'Usage:  If testRangeisNumberedParagraph(Application.Selection.Range) Then

    testRangeisNumberedParagraph = False
    Select Case rng.ListFormat.ListType
        Case wdListListNumOnly, wdListMixedNumbering, wdListOutlineNumbering, wdListSimpleNumbering
            If rng.Start = rng.Paragraphs(1).Range.Start And rng.Characters.Count = 1 Then
                testRangeisNumberedParagraph = True
            End If
    End Select

End Function

Open in new window


Chris
0
 
LVL 15

Author Comment

by:DrTribos
ID: 40011043
Cool thanks Chris - will test when I am back at the PC
0
 
LVL 15

Author Comment

by:DrTribos
ID: 40012046
Hi Chris - I believe that works, thanks :-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question