Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
WORD, how do i place a SIMPLE BRIGHT bookmark to save my place | Microsoft Word Help | |||
Tricky: Word Table Conditional Formatting | Tables | |||
How do I do a inteliigent "find and replace" operation? | Formatting Long Documents | |||
Match Case in Find Operation | Microsoft Word Help | |||
Tricky Template stuff...Different graphics on the first page | Page Layout |