View Single Post
 
Old 03-14-2021, 02:33 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,161
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

OK, try this code which collapses the range to test whether the bookmarked range starts with hidden formatting.
Code:
Sub useFormInhaltFuellen()
  'nach Reihenfolge im Doku sortiert
  'ohne Kopf- und Fußzeile
  Dim aDoc As Word.Document, aBkmk As Bookmark, v As String
  Dim aRng As Range, strArray() As String
  
  Set aDoc = ActiveDocument
  If aDoc.Bookmarks.Count = 0 Then
    MsgBox "kein Textmarken im Dokument enthalten!"
    Exit Sub
  End If
  
  For Each aBkmk In aDoc.Bookmarks
    Set aRng = aBkmk.Range
    aRng.Collapse Direction:=wdCollapseStart
    If Not aRng.Font.Hidden Then
      v = v & "|" & aBkmk.Name
    End If
  Next aBkmk
  v = Mid(v, 2)                      'remove the leading separator
  strArray = Split(v, "|")
  ufInhalt.ListBox1.List = strArray  'Listbox1 eintragen
End Sub
I didn't work out why you looped through every storytype to only only work with the main body of the document so I left that out of my code.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote