<grr>
Right you are.
Have a nice day.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Gentlemen:
I am indebted to you both and please accept my sincerest thanks.
If I may: The eventual outcome was to find if document 2 contained a
sentence in document 1, which I managed to do (I used Herr Weber's code as I
had not seen Mr. Maxey's post at the time - my code follows below), but I
have an odd dilemma.
I resize both documents (crudely) to see both sentences. I select a
sentence in document 1 and it finds it quite well in document 2.
The problem is after resizing, document 1 displays at the beginning of the
document and not the sentence I selected.
Is there a way to return to the selected sentence in document 1 after the
resizing?
Again, my sincerest thanks to you both. I have learned much from
experimenting with your replies.
Thank you.
John
p.s. - I understand Mr. Maxey's point as I experienced some anomalous
returns when running the my initial code
=========================
Sub FindSentence()
Dim x As Long ' number of sentences
Dim i As Long '
Dim s As String
s = Selection
'resize window vertically at top
Application.WindowState = wdWindowStateNormal
Application.Move Left:=0, Top:=0
Application.Resize Width:=768, Height:=275
'Activate other document
Windows("TEST2.doc").Activate
'resize window vertically at bottom
Application.WindowState = wdWindowStateNormal
Application.Resize Width:=768, Height:=275
Application.Move Left:=0, Top:=251
'find sentence from Test1.doc in Test2.doc
With ActiveDocument.Range.Sentences
x = .Count
For i = 1 To x - 1
If .Item(i).Text = s Then
.Item(i).Select
Exit Sub
End If
Next i
End With
End Sub
> Helmut,
>
[quoted text clipped - 90 lines]
> > Win XP, Office 2003
> > "red.sys" & Chr$(64) & "t-online.de"
Jonathan West - 02 Aug 2006 20:09 GMT
> Gentlemen:
>
[quoted text clipped - 10 lines]
> Is there a way to return to the selected sentence in document 1 after the
> resizing?
Look up the ScrollIntoView method in the Word VBA Help file.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
John Kaurloto - 02 Aug 2006 20:27 GMT
Thank you, Sir.
How mystifying when one is ignorant, how easy once one is shown.
My appreciation to you all.
John
> > Gentlemen:
> >
[quoted text clipped - 12 lines]
>
> Look up the ScrollIntoView method in the Word VBA Help file.
Greg Maxey - 02 Aug 2006 20:17 GMT
John,
As Jonathan suggested use the ScrollIntoView method. Also in your
application I think you will want to change for i = 1 to x -1 back to
for i = 1 to x.
Using your code as is you will have problems is you select a sentence
including the trailing space in test1.doc and it is matched by a
sentence at the end of a paragraph in test2.doc.
Sub FindSentence()
Dim x As Long ' number of sentences
Dim i As Long '
Dim s As String
s = Selection
'resize window vertically at top
Application.WindowState = wdWindowStateNormal
Application.Move Left:=0, Top:=0
Application.Resize Width:=768, Height:=275
ActiveWindow.ScrollIntoView Selection.Range, True
'Activate other document
Windows("TEST2.doc").Activate
'resize window vertically at bottom
Application.WindowState = wdWindowStateNormal
Application.Resize Width:=768, Height:=275
Application.Move Left:=0, Top:=251
'find sentence from Test1.doc in Test2.doc
With ActiveDocument.Range.Sentences
x = .Count
For i = 1 To x
If .Item(i).Text = s Then
.Item(i).Select
Exit Sub
End If
Next i
End With
End Sub
> Gentlemen:
>
[quoted text clipped - 141 lines]
> > > Win XP, Office 2003
> > > "red.sys" & Chr$(64) & "t-online.de"
Greg Maxey - 02 Aug 2006 20:24 GMT
John,
You might consider the following to dress up "crudely" :-)
Sub FindSentence()
Dim x As Long ' number of sentences
Dim i As Long '
Dim s As String
s = Selection
Windows.Arrange
ActiveWindow.ScrollIntoView Selection.Range, True
Windows("TEST2.doc").Activate
'find sentence from Test1.doc in Test2.doc
With ActiveDocument.Range.Sentences
x = .Count
For i = 1 To x
If .Item(i).Text = s Then
.Item(i).Select
Exit Sub
End If
Next i
End With
End Sub
> Gentlemen:
>
[quoted text clipped - 141 lines]
> > > Win XP, Office 2003
> > > "red.sys" & Chr$(64) & "t-online.de"
John Kaurloto - 02 Aug 2006 20:42 GMT
WOW!
Thanks...
Cleaner and faster...
Really, thank you.
You also wrote previously:
> Using your code as is you will have problems is you select a sentence
> including the trailing space in test1.doc and it is matched by a
> sentence at the end of a paragraph in test2.doc.
I will correct for this next....
And with what you all gave me, I'm confident I can manage this...
Quite a different attitude from this morning.
:-)
> John,
>
[quoted text clipped - 165 lines]
> > > > Win XP, Office 2003
> > > > "red.sys" & Chr$(64) & "t-online.de"