View Single Post
 
Old 02-11-2021, 02:00 AM
SamDsouza SamDsouza is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

OMG ! I've misunderstood the bookmark

What i wanted was

if paragraph had a book mark
Wanted its name and against the para number

if you see the loop
Each Para is returning the value is like .Alignment , .Range.Font.Name with this wanted addtioinally the bookMark.name if existed against the Paragrpah number

Code:
Public Sub ListBasicReturnedObjects3()

Dim wdActDoc As Document
Dim oBkMrk As Bookmark
Dim StrData As String, StrSty As String, Sty As Style, strstylen As Integer
Dim StrStory As String
Dim gapBetween As Integer
Dim i As Long, j As Long, k As Long, bTabOK As Boolean, Rng As Range
Dim bldFont As Boolean, undline As Boolean, stkThru As Boolean, strHeader As String, Pos As Integer, newPos As Integer
Dim StrRecord As String
                                                  
Set wdActDoc = ActiveDocument
                                                  '15
strHeader = "Para No" & Space(5) & "Style" & Space(12) & "Alignment" & Space(2) & "Font Name" & Space(24) & "BookMark"

StrData = strHeader & vbCrLf

With wdActDoc
  For i = 1 To .Range.Paragraphs.Count
    With .Paragraphs(i)
          StrSty = .Style
          StrData = StrData & vbCr & Format(i, "#00#") & Space(8) & Mid(StrSty, 1, Len(StrSty))
                
       Set Sty = wdActDoc.Styles(StrSty)
             If Len(.Style) <= 11 Then
                StrData = StrData & Space(8) & .Alignment & Space(8) & .Range.Font.Name   
              Else
                StrData = StrData & Space(8) & .Alignment & Space(8) & .Range.Font.Name
             End If

What should be the code here in this loop if there is a book mark in the Para of Active document
BkMark-Para2 is the bookmark.name. As Para 2 was selected and Book mark name was given as BkMark-Para2
Please  see the quoted representation 
       
       
    End With
   Next
  TextBox1.Text = TextBox1.Text & StrData

End With

End Sub
Quote:
Para No Style Alignment Font Name BookMark

001 Normal (Web) 0 Arial
002 Normal (Web) 0 Arial BkMark-Para2
003 Normal (Web) 0 Times New Roman
004 Normal (Web) 0 Arial
005 Normal (Web) 0 Arial
006 Normal (Web) 0 Arial
007 Normal (Web) 0 Arial
008 Normal (Web) 0 Arial
009 Normal (Web) 0 Arial
010 Normal (Web) 0 Arial
011 Normal (Web) 0 Arial
012 Normal (Web) 0 Arial
013 Normal 0 Arial
SamD
Reply With Quote