M
Mido
Hello folks, first of all I would like to thank you for your effort and
great help.
I wrote a macro that I use to translate short texts into French.
I worked on the assumption that the first lines of the macro are
executed first, so I used the macro to search for exact phrase match in
the first lines of code and replace them with exact phrase match in
English.
Then I started using find and replace for single words. I did this to
avoid changing words at the beginning from Phrases where the meaning is
more than just the combination.
My code looked something like this:
Sub French()
'
' Translate phrases and words from English into French
' Translate phrases first then the single words
' Use blue for the translated words to verify the translation
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "First game begins"
.Replacement.Text = "Jeu commence"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Floral Cart"
.Replacement.Text = "Chariot de fleurs"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Cart"
.Replacement.Text = "Chariot"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
To trim the code I then excluded all the instances of False such as
..MatchCase = False
unless it was absolutly necessary for the language issue. So my code
now looks something like this:
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "First game begins"
.Replacement.Text = "Jeu commence"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Floral Cart"
.Replacement.Text = "Chariot de fleurs"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Cart"
.Replacement.Text = "Chariot"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
The Macro seem to be working fine, but there are simply too many lines
wich makes it difficult to maintain and it consumes lots of ressources
as I have hundreds and hundreds of line. Is there is a simpler way to
serach and change a specific phrases, word combination and then single
words? Should I keep all the statements with the False value or am I
right in deleting them?
Thanks a lot for your help!
great help.
I wrote a macro that I use to translate short texts into French.
I worked on the assumption that the first lines of the macro are
executed first, so I used the macro to search for exact phrase match in
the first lines of code and replace them with exact phrase match in
English.
Then I started using find and replace for single words. I did this to
avoid changing words at the beginning from Phrases where the meaning is
more than just the combination.
My code looked something like this:
Sub French()
'
' Translate phrases and words from English into French
' Translate phrases first then the single words
' Use blue for the translated words to verify the translation
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "First game begins"
.Replacement.Text = "Jeu commence"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Floral Cart"
.Replacement.Text = "Chariot de fleurs"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Cart"
.Replacement.Text = "Chariot"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
To trim the code I then excluded all the instances of False such as
..MatchCase = False
unless it was absolutly necessary for the language issue. So my code
now looks something like this:
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "First game begins"
.Replacement.Text = "Jeu commence"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Floral Cart"
.Replacement.Text = "Chariot de fleurs"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Cart"
.Replacement.Text = "Chariot"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
The Macro seem to be working fine, but there are simply too many lines
wich makes it difficult to maintain and it consumes lots of ressources
as I have hundreds and hundreds of line. Is there is a simpler way to
serach and change a specific phrases, word combination and then single
words? Should I keep all the statements with the False value or am I
right in deleting them?
Thanks a lot for your help!