Solved

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

Posted on 2014-04-19
3
496 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
  • 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 14

Author Comment

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

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now