Solved

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

Posted on 2014-04-19
3
506 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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Outlook Free & Paid Tools
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

840 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