?
Solved

VBA to return Heading Number of numbered paragraph

Posted on 2013-05-17
2
Medium Priority
?
1,133 Views
Last Modified: 2013-05-19
Hi All

I would like to find the heading numbers of the selected paragraph using VBA - thought this would be simple but I am flummoxed.

Eg.  I am using outline numbering or heading numbering and my text looks like this:

1.   Trees
1.1 Gum
1.2 Oak
1.3 Terpentine

My cursor is on Oak.  I want VBA to return "1.2"
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 Comments
 
LVL 15

Accepted Solution

by:
DrTribos earned 0 total points
ID: 39176444
Never mind... I got it..
Sub getP()
Dim pPara As Paragraph
Dim sPara As String
Dim rPara As Range

Set pPara = Selection.Paragraphs(1)
Set rPara = pPara.Range
Debug.Print rPara.ListFormat.ListString & " " & rPara.Text

End Sub

Open in new window

0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Suggested Courses

777 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