From: rubendelafuente on
I am trying to write a macro to post-process machine translated files.
One of the issues with translation from EN to ES is that "please"+
command normally is translated without please, just the command. It
would be a tedious task for post editors to delete every occurrence of
"please" translation and the upper case the next sentence.
From: rubendelafuente on
On Jun 8, 11:11 am, rubendelafuente <ruben.rdelafue...(a)gmail.com>
wrote:
> I am trying to write a macro to post-process machine translated files.
> One of the issues with translation from EN to ES is that "please"+
> command normally is translated without please, just the command. It
> would be a tedious task for post editors to delete every occurrence of
> "please" translation and the upper case the next sentence.

So here's the code I wrote. Problem is that the macro works ok but for
the last occurrence of "por favor, +command", when it gets stuck
changing the case of the next word over and over. I guess the problem
is the loop is infinite. Any ideas on how to close it? Thanks in
advance beforehand.

Sub ruboPostEdit()
'
' ruboPostEdit Macro
'
'
Do
Selection.Find.ClearFormatting
With Selection.Find
.Text = "por favor, " 'Searches por favor,
.Replacement.Text = "" 'replaces string above for nothing
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
End With
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdNextCase 'switches next word to upper
case
Loop

End Sub

From: Dave O. on

"rubendelafuente" <ruben.rdelafuente(a)gmail.com> wrote in message
news:8f6393e6-4c3f-4f61-81fe-6d93380c9607(a)c10g2000yqi.googlegroups.com...
On Jun 8, 11:11 am, rubendelafuente <ruben.rdelafue...(a)gmail.com>
wrote:
> I am trying to write a macro to post-process machine translated files.
> One of the issues with translation from EN to ES is that "please"+
> command normally is translated without please, just the command. It
> would be a tedious task for post editors to delete every occurrence of
> "please" translation and the upper case the next sentence.

So here's the code I wrote. Problem is that the macro works ok but for
the last occurrence of "por favor, +command", when it gets stuck
changing the case of the next word over and over. I guess the problem
is the loop is infinite. Any ideas on how to close it? Thanks in
advance beforehand.

Sub ruboPostEdit()
'
' ruboPostEdit Macro
'
'
Do
Selection.Find.ClearFormatting
With Selection.Find
.Text = "por favor, " 'Searches por favor,
.Replacement.Text = "" 'replaces string above for nothing
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
End With
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdNextCase 'switches next word to upper
case
Loop

End Sub

2 points

This looks like VB.Net, this newsgroup is for VB6 and is doomed, MS are
going to kill it soon
You should post to:
microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data
microsoft.public.dotnet.general
microsoft.public.vsnet.general

Assuming that Do & Loop work as I expect , you have not given any exit
condition so of course the loop will loop for ever.

If this were real VB you would either have
Do While something = something else
-- or --
Loop Until something = something else

DaveO.


From: rubendelafuente on
On Jun 8, 12:26 pm, "Dave O." <nob...(a)nowhere.com> wrote:
> "rubendelafuente" <ruben.rdelafue...(a)gmail.com> wrote in message
>
> news:8f6393e6-4c3f-4f61-81fe-6d93380c9607(a)c10g2000yqi.googlegroups.com...
> On Jun 8, 11:11 am, rubendelafuente <ruben.rdelafue...(a)gmail.com>
> wrote:
>
> > I am trying to write a macro to post-process machine translated files.
> > One of the issues with translation from EN to ES is that "please"+
> > command normally is translated without please, just the command. It
> > would be a tedious task for post editors to delete every occurrence of
> > "please" translation and the upper case the next sentence.
>
> So here's the code I wrote. Problem is that the macro works ok but for
> the last occurrence of "por favor, +command", when it gets stuck
> changing the case of the next word over and over. I guess the problem
> is the loop is infinite. Any ideas on how to close it? Thanks in
> advance beforehand.
>
> Sub ruboPostEdit()
> '
> ' ruboPostEdit Macro
> '
> '
> Do
> Selection.Find.ClearFormatting
>     With Selection.Find
>         .Text = "por favor, " 'Searches por favor,
>         .Replacement.Text = "" 'replaces string above for nothing
>         .Forward = True
>         .Wrap = wdFindContinue
>         .Format = False
>         .MatchCase = False
>         .MatchWholeWord = False
>         .MatchWildcards = False
>         .MatchSoundsLike = False
>         .MatchAllWordForms = False
>     End With
>     Selection.Find.Execute
>     With Selection
>         If .Find.Forward = True Then
>             .Collapse Direction:=wdCollapseStart
>         Else
>             .Collapse Direction:=wdCollapseEnd
>         End If
>         .Find.Execute Replace:=wdReplaceOne
>         End With
>         Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
>     Selection.Range.Case = wdNextCase 'switches next word to upper
> case
>     Loop
>
> End Sub
>
> 2 points
>
> This looks like VB.Net, this newsgroup is for VB6 and is doomed, MS are
> going to kill it soon
> You should post to:
> microsoft.public.dotnet.languages.vb
> microsoft.public.dotnet.languages.vb.upgrade
> microsoft.public.dotnet.languages.vb.controls
> microsoft.public.dotnet.languages.vb.data
> microsoft.public.dotnet.general
> microsoft.public.vsnet.general
>
> Assuming that Do & Loop work as I expect , you have not given any exit
> condition so of course the loop will loop for ever.
>
> If this were real VB you would either have
> Do While something = something else
>   --  or  --
> Loop Until something = something else
>
> DaveO.

Hi Dave

I have tried several ways to give an exit condition, but the result
was the same.

I have tried Loop While Selection.Find.Text = "por favor, " = true,
for instance

Basically, exit condition would be: stop when text string not found. I
am just not familiar enough with VB to code that properly.

Thanks in advance for your help.
From: Helmut Meukel on
"Dave O." <nobody(a)nowhere.com> schrieb im Newsbeitrag
news:OCWNNUvBLHA.3880(a)TK2MSFTNGP04.phx.gbl...
>
> "rubendelafuente" <ruben.rdelafuente(a)gmail.com> wrote in message
> news:8f6393e6-4c3f-4f61-81fe-6d93380c9607(a)c10g2000yqi.googlegroups.com...
> On Jun 8, 11:11 am, rubendelafuente <ruben.rdelafue...(a)gmail.com>
> wrote:
>> I am trying to write a macro to post-process machine translated files.
>> One of the issues with translation from EN to ES is that "please"+
>> command normally is translated without please, just the command. It
>> would be a tedious task for post editors to delete every occurrence of
>> "please" translation and the upper case the next sentence.
>
> So here's the code I wrote. Problem is that the macro works ok but for
> the last occurrence of "por favor, +command", when it gets stuck
> changing the case of the next word over and over. I guess the problem
> is the loop is infinite. Any ideas on how to close it? Thanks in
> advance beforehand.
>
> Sub ruboPostEdit()
> '
> ' ruboPostEdit Macro
> '
> '
> Do
> Selection.Find.ClearFormatting
> With Selection.Find
> .Text = "por favor, " 'Searches por favor,
> .Replacement.Text = "" 'replaces string above for nothing
> .Forward = True
> .Wrap = wdFindContinue
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchWildcards = False
> .MatchSoundsLike = False
> .MatchAllWordForms = False
> End With
> Selection.Find.Execute
> With Selection
> If .Find.Forward = True Then
> .Collapse Direction:=wdCollapseStart
> Else
> .Collapse Direction:=wdCollapseEnd
> End If
> .Find.Execute Replace:=wdReplaceOne
> End With
> Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdNextCase 'switches next word to upper
> case
> Loop
>
> End Sub
>
> 2 points
>
> This looks like VB.Net, this newsgroup is for VB6 and is doomed, MS are going
> to kill it soon
> You should post to:
> microsoft.public.dotnet.languages.vb
> microsoft.public.dotnet.languages.vb.upgrade
> microsoft.public.dotnet.languages.vb.controls
> microsoft.public.dotnet.languages.vb.data
> microsoft.public.dotnet.general
> microsoft.public.vsnet.general
>
> Assuming that Do & Loop work as I expect , you have not given any exit
> condition so of course the loop will loop for ever.
>
> If this were real VB you would either have
> Do While something = something else
> -- or --
> Loop Until something = something else
>
> DaveO.
>


Dave, it's VBA (using the Word object model).
I'm not familiar enough with Word (never programmed
Word with VBA) to spot the problem.

Helmut.

 |  Next  |  Last
Pages: 1 2
Prev: Bug or feature?
Next: VB Macro to VB Application