View Full Version : Solved: Find and repalce
Pasquale
08-22-2005, 09:54 AM
Hallo I need still help for my biblical study.
I need to insert a square bracket ] at the end of some number:
sample
My doc has [Aaa ##0,##0 d others word others word others word
Bold is for sample
I must be replace the space and the letter situated after ,##0
sample
[Gen 1,1 c others words others words others words
replaced with
[Gen 1,1] others words others words others words
sample
[Gen 21,10 e others words others words others words
replaced with
[Gen 21,10] others words others words others words
Bold is for sample
At the begin of every paragraph there is:
A square bracket [
Three characters (sample Gen Exo Lev ecc ecc)
A space
A number with 1, 2 or 3 cyphers
A comma
A number with 1, 2 or 3 cyphers
A space
A character of one letter (sample one of this letters: a b c d e f g h i l m n o p q r s t u v z)
A space
Others different words
I need to delete 7 and 8 and to write a square bracket ]
pasquale:help :help :help
fumei
08-22-2005, 10:53 AM
Sub NewReplace()
Dim oRange As Word.Range
Dim lngEnd As Long
Selection.HomeKey unit:=wdStory
With Selection.Find
.ClearFormatting
.Wrap = wdFindStop
Do While (.Execute(findtext:="[Gen ", Forward:=True) = True = True)
Set oRange = Selection.Range
oRange.MoveEndUntil _
Cset:="abcdefghijklmnopqrstuvwxyz", _
Count:=10
oRange.MoveEnd unit:=wdCharacter, Count:=2
With Selection
.SetRange Start:=Selection.Range.Start, _
End:=oRange.End
.Collapse direction:=wdCollapseEnd
.MoveStart unit:=wdCharacter, Count:=-3
.Delete
.TypeText Text:="]"
.Collapse direction:=wdCollapseEnd
End With
Set oRange = Nothing
Loop
End With
End Sub
will do what you want. Although it does use the Selection object, rather than the range. I was getting strange things with the Range...tired.
Pasquale
08-22-2005, 11:28 AM
Hi Gerry
it is superb
Thanks
I test it
TonyJollans
08-22-2005, 12:28 PM
Hi Pasquale,
You should make an effort to learn how to use patterns in Find/Replace.
Again, this doesn't need code (although you can record it if you want). In Word:
Ctrl+h (to get the dialog)
Find what: (\[??? [0-9]{1,3},[0-9]{1,3}) [a-z]( )
Replace with: \1]\2
Check Use Wildcards
Hit Replace All
Pasquale
08-22-2005, 12:51 PM
Hi Tony,
I before to post a new thread attempt many time to use find and replace or to record a macro, but the effect isn't good.
At the end I post a thread.
Pasquale
TonyJollans
08-22-2005, 02:52 PM
It comes with practice :)
fumei
08-23-2005, 01:10 PM
Tony is right though. Using existing dialogs, and the various patterns and wildcards that are available, is generally, an easier way to do things. that is why they are there.
However, glad it worked for you.
Pasquale
08-23-2005, 01:33 PM
Hi Fumei
many thanks.
But I have another problem, but I don't want to post another thread.
My Other doc have this form ##0,##0 d others word others word others word
Bold is for sample
I must be insert at the beginning of every lines a square bracket [ , replace the space and the letter situated after ,##0
sample
1,1 c others words others words others words
replaced with
[1,1] others words others words others words
sample
21,10 e others words others words others words
replaced with
[21,10] others words others words others words
Bold is for sample
At the begin of every paragraph there is:
A number with 1, 2 or 3 cyphers
A comma
A number with 1, 2 or 3 cyphers
A space
A character of one letter (sample one of this letters: a b c d e f g h i l m n o p q r s t u v z)
A space
Others different words
I need to insert at the begin of every lines a square bracket [, delete 6 and 7 and to write a square bracket], let a space after square bracket ] without change the formatting of doc.
How can change your macro for this?
Thanks for help
Pasquale
fumei
08-23-2005, 01:42 PM
I suggest:
1. take a good look at Tony's post.
2. take a good look at mine.
Pasquale
08-23-2005, 01:56 PM
Hi Fumei
Thanks
Pasquale
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.