Solved

VBA to return Heading Number of numbered paragraph

Posted on 2013-05-17
2
949 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
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
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…

831 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