Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
binar binar is offline
external usenet poster
 
Posts: 90
Default Need Help with a Tricky Find & Place Operation

Fellow Forum Members,
My manual has at least 100 Figure cross references that look like this:
(Figure3-2).

My goal is to add the word "see" right before the "F" so that it can read
like this:
(see Figure 3-2).

I want to use Word's Find & Replace feature, but the problem is that "Figure
3-2" is field data that is not recognizable by the Find & Replace feature.
How do I fool the Find & Replace feature so that it recognizes the field
"Figure" ? I want Find & Replace to look for "(F" and replace it with "(see
F".

I tried it and it doesn't work. I need a better way. Any help will be
appreciated. Thanks.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Bear Bear is offline
external usenet poster
 
Posts: 39
Default Need Help with a Tricky Find & Place Operation

Binar:

I hope someone can provide a better solution, but I don't think the built-in
Find and Replace function will work for you. Any time it succeeds it puts
your new text inside the field, and that means it will be deleted when the
field is updated.

I think your best bet would be to record a macro, where you use Find to
locate the cross-reference, then cancel the Find, leaving the cross-reference
selected. Next, press the left arrow key twice to move the insertion point
outside the field, and type " see" to insert the word. Finally, use the right
arrow key to move the insertion point past the word "Figure" that you just
found, and end the macro.

If you ran this repeatedly, it would eventually get you there. The big
problem is that I don't think you want to make a global replacement. In my
test manual, for example, not all cross-references were of that form. Some
said "... as shown in Figure 3-2." In a case like that, you wouldn't want to
insert the "see."

So in the end, you'd have to learn enough VBA to modify the macro to find a
cross-reference, ask you if you wanted to do the insertion, and act
accordingly.

If you want to try that, please let me know, and I'll help you develop a
solution further.

Bear
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default Need Help with a Tricky Find & Place Operation

For the reasons Bear mentioned you might want to steer clear of Find
and Replace. This may do:


Sub Test()
Dim oFld As Word.Field
For Each oFld In ActiveDocument.Fields
If InStr(oFld.Result, "Figure 3-2") = 1 Then
oFld.Select
Selection.Collapse wdCollapseStart
Selection.InsertBefore "See "
End If
Next
End Sub

On Apr 18, 4:44 pm, binar wrote:
Fellow Forum Members,
My manual has at least 100 Figure cross references that look like this:
(Figure3-2).

My goal is to add the word "see" right before the "F" so that it can read
like this:
(see Figure 3-2).

I want to use Word's Find & Replace feature, but the problem is that "Figure
3-2" is field data that is not recognizable by the Find & Replace feature.
How do I fool the Find & Replace feature so that it recognizes the field
"Figure" ? I want Find & Replace to look for "(F" and replace it with "(see
F".

I tried it and it doesn't work. I need a better way. Any help will be
appreciated. Thanks.



  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Bear Bear is offline
external usenet poster
 
Posts: 39
Default Need Help with a Tricky Find & Place Operation

Binar:

Since Greg did most of the hard work, I polished it off with the details.
First, not all fields have a Result, so I tested to work only with REF
fields. Second, I added the decision-making option. Finally, I added a
message to signal completion. It's not perfect, as we still haven't destroyed
the object. But that's for another iteration.

Bear


Sub Test()

Dim oFld As Word.Field
Dim sReply As String

For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldRef Then
If InStr(oFld.Result, "Figure") = 1 Then
oFld.Select
sReply = MsgBox("Change this?", vbYesNoCancel + vbQuestion,
"OmniTools")
Select Case sReply
Case vbYes
Selection.Collapse wdCollapseStart
Selection.InsertBefore "see "
Case vbNo
Selection.Collapse Direction:=wdCollapseEnd
Case vbCancel
Exit Sub
End Select
End If
End If
Next
MsgBox "All fields have been tested.", vbInformation, "OmniTools"

End Sub


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default Need Help with a Tricky Find & Place Operation

Polishes well recieved. Thanks.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Bear wrote:
Binar:

Since Greg did most of the hard work, I polished it off with the
details. First, not all fields have a Result, so I tested to work
only with REF fields. Second, I added the decision-making option.
Finally, I added a message to signal completion. It's not perfect, as
we still haven't destroyed the object. But that's for another
iteration.

Bear


Sub Test()

Dim oFld As Word.Field
Dim sReply As String

For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldRef Then
If InStr(oFld.Result, "Figure") = 1 Then
oFld.Select
sReply = MsgBox("Change this?", vbYesNoCancel + vbQuestion,
"OmniTools")
Select Case sReply
Case vbYes
Selection.Collapse wdCollapseStart
Selection.InsertBefore "see "
Case vbNo
Selection.Collapse Direction:=wdCollapseEnd
Case vbCancel
Exit Sub
End Select
End If
End If
Next
MsgBox "All fields have been tested.", vbInformation, "OmniTools"

End Sub



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WORD, how do i place a SIMPLE BRIGHT bookmark to save my place Peter Microsoft Word Help 2 September 30th 06 10:22 PM
Tricky: Word Table Conditional Formatting TomorrowsMan Tables 8 April 18th 06 11:35 PM
How do I do a inteliigent "find and replace" operation? MegaC Formatting Long Documents 1 March 2nd 06 07:59 PM
Match Case in Find Operation Leonard Microsoft Word Help 0 October 19th 05 08:40 PM
Tricky Template stuff...Different graphics on the first page Michael Gould Page Layout 3 March 17th 05 10:23 PM


All times are GMT +1. The time now is 09:53 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"