makro mehrmals ausführen

  • #1
C

chrigi

Guest
wenn ich folgendes makro ausführe, wird das von mir gewünschte genau 1 mal durchgeführt. ich hätte aber gerne, dass das makro den gesamten text durchgeht, also bis ans ende des dokumentes. was muss ich tun?


Code:
Sub verschieben1()
  
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = @ort!
        .Replacement.Text = ^&
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
    Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Cut
    Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
    Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
    Selection.HomeKey Unit:=wdLine
    Selection.MoveUp Unit:=wdParagraph, Count:=1
    Selection.Paste
    
End Sub
 
  • #2
Hallo

Ich habe hier das gleiche Problem. Weiss niemand wie das geht?

Danke
 
  • #3
Hi zusammen,

eine Lösung wäre
Code:
Sub verschieben1()
  
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = @ort!
        .Replacement.Text = ^&
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
      Do While .Execute = True
        Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
        Selection.Cut
        Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.HomeKey Unit:=wdLine
        Selection.MoveUp Unit:=wdParagraph, Count:=1
        Selection.Paste
      Loop
    End With
    
End Sub

Gruß Matjes  ;)
 
Thema:

makro mehrmals ausführen

ANGEBOTE & SPONSOREN

Statistik des Forums

Themen
113.840
Beiträge
707.965
Mitglieder
51.494
Neuestes Mitglied
Flensburg45
Oben