Unfortunately, you have hot on onw of the few things which a Selection is
really needed for - navigating by lines.
Is each line a separate paragraph? If so, I could do a per-paragraph
equivalent?
Also, since this is code controlling Word from outside, could you include
the code where you declare and initialise oWordApp and open the document? I
need to see whether you are using early or late binding
--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup
mpalma said:
Thank you Jonathan.
Here is an example of the code:
oWordApp.Selection.HomeKey wdStory
oWordApp.Selection.MoveUp wdLine
oWordApp.Selection.MoveDown wdLine, 1, wdExtend
oWordApp.Selection.Delete
oWordApp.Selection.MoveDown wdLine, 1, wdExtend
If InStr(oWordApp.Selection.Text, "-") > 0 Then
oWordApp.Selection.HomeKey wdLine
While oWordApp.Selection.Text <> "("
oWordApp.Selection.Delete
Wend
oWordApp.Selection.Delete
While Right(oWordApp.Selection.Text, 1) <> ")"
oWordApp.Selection.MoveRight , , wdExtend
Wend
oWordApp.Selection.MoveLeft , , wdExtend
Else
While InStr(oWordApp.Selection.Text, " ") > 0
oWordApp.Selection.MoveLeft , , wdExtend
Wend
End If
lngPagina = Val(oWordApp.Selection.Text)
oWordApp.Selection.MoveLeft
oWordApp.Selection.MoveDown wdLine, 1, wdExtend
oWordApp.Selection.Delete
This is a the range equivalent
Dim wrdRange as Object
Set wrdRange = oWordApp.ActiveDocument.Range(0, 0)
oWordApp.Selection.HomeKey wdStory
oWordApp.Selection.MoveUp wdLine
oWordApp.Selection.MoveDown wdLine, 1, wdExtend
oWordApp.Selection.Delete
oWordApp.Selection.MoveDown wdLine, 1, wdExtend
If InStr(oWordApp.Selection.Text, "-") > 0 Then
oWordApp.Selection.HomeKey wdLine
While oWordApp.Selection.Text <> "("
oWordApp.Selection.Delete
Wend
oWordApp.Selection.Delete
While Right(oWordApp.Selection.Text, 1) <> ")"
oWordApp.Selection.MoveRight , , wdExtend
Wend
oWordApp.Selection.MoveLeft , , wdExtend
Else
While InStr(oWordApp.Selection.Text, " ") > 0
oWordApp.Selection.MoveLeft , , wdExtend
Wend
End If
lngPagina = Val(oWordApp.Selection.Text)
oWordApp.Selection.MoveLeft
oWordApp.Selection.MoveDown wdLine, 1, wdExtend
oWordApp.Selection.Delete