From: Paul Clement on
On Tue, 8 Jun 2010 02:16:46 -0700 (PDT), rubendelafuente <ruben.rdelafuente(a)gmail.com> wrote:

� 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

I would recommend posting your question to the MSDN Word for Developers forum.

http://social.msdn.microsoft.com/Forums/en-US/worddev/threads


Paul
~~~~
Microsoft MVP (Visual Basic)
From: rubendelafuente on
On Jun 8, 2:33 pm, Paul Clement
<UseAdddressAtEndofMess...(a)swspectrum.com> wrote:
> On Tue, 8 Jun 2010 02:16:46 -0700 (PDT), rubendelafuente <ruben.rdelafue....(a)gmail.com> wrote:
>
> ¤ 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
>
> I would recommend posting your question to the MSDN Word for Developers forum.
>
> http://social.msdn.microsoft.com/Forums/en-US/worddev/threads
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)

Sounds good, Paul. Will do. Thx everybody.
First  |  Prev  | 
Pages: 1 2
Prev: Bug or feature?
Next: VB Macro to VB Application