View Single Post
 
Old 11-10-2020, 06:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes it is possible but it is always going to be slightly dodgy because we don't have exposure to your actual documents so we have to make a guess on what pattern is most robust to identify your 'List' area.

Change this line:
Set aRng = docCurrent.Bookmarks("ListArea").Range

to:
Set aRng = GetListRange(docCurrent)

and add this function to the module
Code:
Function GetListRange(aDoc As Document) As Range
  Dim aRng As Word.Range, iStart As Long, iEnd As Long
  Set aRng = aDoc.Range
  With aRng.Find
    .ClearFormatting
    .Wrap = wdFindStop
    .MatchCase = True
    .MatchWildcards = False
    .Text = "LIST"
    If .Execute Then iStart = aRng.End
    aRng.End = aDoc.Range.End
    .Text = "ABSTRACT"
    If .Execute Then iEnd = aRng.Start
    If iEnd > iStart Then
      Set GetListRange = aDoc.Range(iStart, iEnd)
    End If
  End With
End Function
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote