Solved

VBA to return Heading Number of numbered paragraph

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

Accepted Solution

by:
DrTribos earned 0 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now