View Single Post
 
Old 06-25-2020, 05:10 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

How about


Code:
Public Function GetVariablesFirstLevel() As Collection
Dim objVar As Variable
Dim colAux As Collection
Dim strAux As String
Dim objStoryRange As Range
Dim i As Integer

    Set colAux = New Collection
    For Each objStoryRange In ActiveDocument.StoryRanges
        With objStoryRange.Find
            .ClearFormatting
            Do While .Execute(findText:="- * -", MatchWildcards:=True)
                'strAux = Trim(Replace(objStoryRange.Text, "-", ""))
                strAux = objStoryRange.Text
                colAux.Add strAux, UCase$(strAux)
                objStoryRange.Collapse 0
            Loop
        End With
    Next objStoryRange
    'For i = 1 To colAux.Count
    'Debug.Print colAux(i)
    '    Next i
    GetVariablesFirstLevel = colAux
    Set colAux = Nothing
    Set objStoryRange = Nothing
    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