Re: Move to tab location in document using paragraph index & tabst

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



It seems to me that what you really want to do is work with Tabs. I haven't tested this fully and I'm sure it can be improved upon, but it will find tabs at custom tab stops - does it help?

Selection.HomeKey Unit:=wdStory
For intCtrPara = 1 To ActiveDocument.Paragraphs.Count
Set objPara = ActiveDocument.Paragraphs(intCtrPara)

Dim objTempRange As Range
Set objTempRange = objPara.Range.Duplicate
With objTempRange.Find
.Text = vbTab
Do While .Execute
If objTempRange.Start > objPara.Range.End Then Exit Do
For Each objTabStop In objPara.TabStops
If objTabStop.Position > objTempRange.Information(wdHorizontalPositionRelativeToPage) Then
' This is the tabstop that this tab character stops at
If objTabStop.CustomTab Then
' it is a custom one - do your stuff here
MsgBox "tab at custom tab stop"
Exit For
End If
End If
Next
Loop
End With

Next

--
Enjoy,
Tony

"LostInMD" <LostInMD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:DE90C9AF-411C-40F8-844E-DECC3238D3C8@xxxxxxxxxxxxxxxx
Hi Tony,

I'm newer to the the 'world of tabstops' and still am finding new things out
about them. Would there be a way to look for a custom tabstop, and upon
finding it, determine if there is an associated tab, and if there is, to move
the cursor to that tab that is associated with the tabstop --> for all custom
tabstops w/in a document? Thanks again for all your help!

"Tony Jollans" wrote:

So you are interested in tabstops whether or not there is a tab in the
paragraph leading to them. I think you're out of luck. There is no way (or
certainly no practical way) to position the cursor at an absolute position
on the page which might be outside the text.

Can you say what you would have liked to do if it were possible?

--
Enjoy,
Tony

"LostInMD" <LostInMD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:98F47145-172D-4644-B48C-0046BD1C43B2@xxxxxxxxxxxxxxxx
> Hi Tony,
>
> The following code is how I retrieve the paragraph and tabstop index > from
> the document:
>
> m_Document.Application.Selection.HomeKey(Unit:=wdStory, Extend:=wdMove)
> For intCtrPara = 1 To m_Document.Paragraphs.Count
> objPara = m_Document.Paragraphs(intCtrPara)
> intCtrTabStop = 0
> For Each objTabStop In objPara.TabStops
> intCtrTabStop = intCtrTabStop + 1
> If objTabStop.CustomTab = True Then
> '*****This is where I would put my cursor > at
> this
> '*****particular tabstop within this
> particular paragraph.
> '*****and do some manipulating of the
> text/tab.
> '*****I only want to manipulate custom tab
> stops.
> End If
> Next
> Next
>
> Thanks for any suggestions you can offer!
>
> "Tony Jollans" wrote:
>
>> What you want may be easy, or may be all but impossible. Hard to tell
>> without some more detail.
>>
>> Do you mean the nth tabstop position whether or not there is a tab in >> the
>> paragraph? This might be off the page.
>>
>> Or do you mean the nth tab in the paragraph whatever tabstop it is at?
>> This
>> could be anywhere in the paragraph and not necessarily at a custom
>> tabstop.
>>
>> Or do you mean the nth custom tab in the paragraph.
>>
>> Or the nth tab at the start of a paragraph - and if so, only if it is >> at
>> the
>> nth tabstop position, or always?
>>
>> And do you only want Left tabs, or all types?
>>
>> -- >> Enjoy,
>> Tony
>>
>> "LostInMD" <LostInMD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:4612EDF4-5E69-4298-9762-7151A24FBFBA@xxxxxxxxxxxxxxxx
>> > Hi All,
>> >
>> > I need to move to a specific tabstop within a document. I know >> > which
>> > paragraph it is in, and know the tabstop index for the tabstop
>> > collection
>> > for
>> > the paragraph it is in. The question is: how do I place my cursor >> > at
>> > the
>> > actual tab in the document that is represented by this tabstop? Ex. >> > I
>> > have
>> > a tabstop in the 4th paragraph of a document. It is the 6th tabstop >> > in
>> > the
>> > paragraph. How do I physically move the cursor to the 6th tab in >> > the
>> > paragraph? Thanks for ANY information you have to offer!
>>
>>



.



Relevant Pages

  • Re: Move to tab location in document using paragraph index & tabst
    ... So you are interested in tabstops whether or not there is a tab in the paragraph leading to them. ... The following code is how I retrieve the paragraph and tabstop index from ... Do you mean the nth tabstop position whether or not there is a tab in the ...
    (microsoft.public.word.vba.customization)
  • Re: How do I insert paragraph marks and tabs in text custom values?
    ... >I defined a text-type custom value, and I need it to include sometimes ... tab character in the document, copying or cutting it to the clipboard, ... The other words in quotes are the regular text in the value -- ... a paragraph mark. ...
    (microsoft.public.word.docmanagement)
  • Re: Move to tab location in document using paragraph index & tabst
    ... Once the tab at the custom tab stop is found, ... ' This is the tabstop that this tab character stops ... The following code is how I retrieve the paragraph and tabstop index ...
    (microsoft.public.word.vba.customization)
  • Re: Move to tab location in document using paragraph index & tabst
    ... The following code is how I retrieve the paragraph and tabstop index from ... intCtrTabStop = intCtrTabStop + 1 ... Do you mean the nth tabstop position whether or not there is a tab in the ...
    (microsoft.public.word.vba.customization)
  • Re: Tab Position
    ... Where the tabs move the cursor to is defined by the TabStops collection of ... the Paragraph or ParagraphFormat object. ... Each Tabstop object has several properties, ... If you know where you think tab 1 ought to be, ...
    (microsoft.public.word.vba.general)