Tab stops

V

Vagabound_s

Hi,

I am trying search for tab stops which go beyond the document page margin
and store in a list. I store those tab stops in a list and in the click event
of the list I want to browse through the paragraph containing those tab stops.

The problem is that only the paragraph which have custom tabstops within the
page margin are selected. for tabstops which are equal to or more than the
page margin entire document is selected. However, If I manually use find
dialogbox, it does select specific paragraph or lines containing those tab
stops.

I am not sure what is going wrong.

The code is as below:

Private Sub TabList_Click()
With ActiveDocument.Content.Find
.ClearFormatting
.Forward = True
.Format = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.ParagraphFormat.TabStops.Add
Position:=InchesToPoints(UserForm1.TabList.Value)
.Text = ""
.Execute
.Parent.Select
End With
End Sub

Code to search for the custom tab stops in the document:

Sub findTabStop()
Dim i As Long
Dim Pmargin As Single
Dim CURRENT_DOCUMENT
Dim FFlag As Boolean
Dim Apara As Paragraph
Dim ATabstop As tabstop
FFlag = False
i = 1
Set CURRENT_DOCUMENT = ActiveDocument
Pmargin = ActiveDocument.PageSetup.RightMargin

For Each Apara In CURRENT_DOCUMENT.Paragraphs()
For Each ATabstop In Apara.TabStops
If ATabstop.CustomTab = True Then
If ATabstop.Position > InchesToPoints(7) Then
FFlag = True
UserForm1.TabList.AddItem
PointsToInches(ATabstop.Position)
End If
End If
'StatusBar = i '& " of " & ActiveDocument.Paragraphs.Count
DoEvents
Next
Next
'MsgBox PointsToInches(Pmargin)

If FFlag = True Then
UserForm1.TabList.Visible = True
UserForm1.TabList.Enabled = True
End If
UserForm1.Show
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top