Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 01-18-2022, 06:03 AM
gmayor's Avatar
gmayor gmayor is offline VBA Help Indent Paragraphs between Headings Windows 10 VBA Help Indent Paragraphs between Headings Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I have given myself a headache trying to work out the various combinations without much success.


The following function will give you the outline level number for a selected paragraph, which should help work out what the previous and following paragraphs are:
Code:
Private Function ListParaNum(oPara As Paragraph) As String
Dim i As Integer
Dim xRefs As Variant
    xRefs = ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem)
    ListParaNum = 0
    With oPara.Range
        If .ListParagraphs.Count = 0 Then
            GoTo lbl_Exit
        End If
        .Collapse wdCollapseEnd
        On Error Resume Next
        For i = 1 To UBound(xRefs)
            If ActiveDocument.ListParagraphs(i).Range.End = .End Then
                ListParaNum = Val(ActiveDocument.ListParagraphs(i).Range.ListFormat.ListString)
                Exit For
            End If
        Next i
    End With
lbl_Exit:
    Exit Function
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Help Indent Paragraphs between Headings Selectively numbered paragraphs based on headings.. WildfireS3 Word 2 05-18-2020 05:18 AM
Indent on headings nerion Word 5 04-11-2019 04:48 AM
Difference between first line Indent and Left Indent kingston123 Word 3 09-25-2018 02:47 PM
Indent of first numbered heading different from subsequent headings ultimateguy Word 1 08-12-2015 06:51 AM
VBA Help Indent Paragraphs between Headings Problem with bold numbers in multi-level list styles when having numbered headings AND paragraphs bwofficer Word 2 12-12-2014 12:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft