Solved

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

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Word macro referencing data 8 30
Help with error when uploading excel file 3 29
Excel 2013: Default workbook 13 30
VB.Net Tranfer data between to VB.Net apps 8 26
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
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…

809 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