Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

623 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