![]() |
#2
|
||||
|
||||
![]()
Assuming by 'line' you mean 'paragraph' then
Code:
Sub Macro1() Dim oPara As Paragraph Dim oRng As Range Dim intPos As Integer For Each oPara In ActiveDocument.Paragraphs Set oRng = oPara.Range oRng.End = oRng.End - 1 'omit the paragraph break from the range If UBound(Split(oRng.Text, Chr(9))) = 2 Then 'ensure there are two tab characters intPos = InStrRev(oRng.Text, Chr(9)) 'Find the second tab character position oRng.Start = oRng.Start + intPos 'move the start of the range to that position MsgBox Trim(oRng.Text) 'this is the text in the paragraph. Trim to remove spurious spaces oRng.Collapse 1 'this is the start of the text portion of the paragrapj End If Next oPara Set oPara = Nothing Set oRng = Nothing End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ducky831 | Excel Programming | 3 | 09-17-2015 01:36 PM |
![]() |
sunriver | Word | 3 | 06-24-2015 07:00 PM |
![]() |
bracketandquotes | Word VBA | 17 | 02-16-2015 03:51 PM |
![]() |
SteveWcg | Word | 5 | 01-08-2014 10:37 PM |
![]() |
ericerler | Mail Merge | 1 | 08-11-2011 05:31 AM |