Quote:
Originally Posted by gmayor
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
|
Hi, thanks for posting that. I'm getting "sub or function not defined" when I run it. I just copied it into a new macro to test it, is there something more I should have done?