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
Solved

VBA to return Heading Number of numbered paragraph

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

840 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