You have to repeat .Execute while the item is found:
Sub Locate_in_Doct()
Dim sExcelTextJ
sExcelTextJ = "3.2.1.1.1.2"
ActiveDocument.Range(0, 0).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = sExcelTextJ
While .Execute
Selection.Collapse Direction:=wdCollapseEnd
If Selection.IPAtEndOfLine = False Then
Selection.EndKey Unit:=wdLine, Extend:=wdMove
End If
Selection.TypeText Text:=vbCrLf & "Locate Here " & vbCrLf
Wend
End With
End Sub
On Mar 7, 8:04 am, "neo2ce...@gmail.com" <neo2ce...@gmail.com> wrote:
> I am pulling a number (eg, 3.2.1.1.1.2) from an Excel doct and then
> trying to locate that position in a Word(2003) doct., and insert some
[quoted text clipped - 32 lines]
> Selection.TypeText Text:=vbCrLf & "Locate Here " & vbCrLf
> End Sub
neo2cents@gmail.com - 07 Mar 2007 17:54 GMT
I tried this but on the call to the sub (new sExcelTextJ value) the
While statement does not execute. I am trying to find out how to reset
the selection properties, but I haven't found it yet. Or is this not
the problem?
> You have to repeat .Execute while the item is found:
>
[quoted text clipped - 55 lines]
>
> - Show quoted text -
neo2cents@gmail.com - 12 Mar 2007 19:16 GMT
The problem I had was not with the selection.find.
When I extracted the string from Excel, I had leading spaces or blanks
that did not
show up in the debugger window. Adding trim$( ) to the Excel string
solved my problem.
Thanks,
On Mar 7, 1:54 pm, "neo2ce...@gmail.com" <neo2ce...@gmail.com> wrote:
> I tried this but on the call to the sub (new sExcelTextJ value) the
> While statement does not execute. I am trying to find out how to reset
[quoted text clipped - 62 lines]
>
> - Show quoted text -