MS-Word宏-替换-下班后确认

时间:2019-01-26 18:37:10

标签: vba replace ms-word word-vba confirmation

我不是工程师,也不是IT工作者。但我是体育记者。

我在旅途中写了许多文章。我使用此Google语音。但是我们对Google语音中的波兰语语言存在一个问题。它不会...转换标点符号。

我在Microsoft Word中创建了宏。但这不是100%令我满意的。完成所有工作后,我无法确认更改。

使用宏后,我需要在其工作后按“ YES”按钮。 MS-Word问我:“ MS-Word完成了对选定文本的搜索。更改数量:0/1/2等。我应该搜索文档的其余部分吗?”。

宏中有11个替换项,每个单词我都需要按YES ... 11次(即使替换为0次):)

我附上了我的Macro,也许您社区中的某人可以帮助并修改我的想法。非常感谢。

Sub GoogleVoice()
'
' GoogleVoice Makro
'
'
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " przecinek"
        .Replacement.Text = ","
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " kropka"
        .Replacement.Text = "."
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " dwukropek"
        .Replacement.Text = ":"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "myślnik"
        .Replacement.Text = "-"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " znak zapytania"
        .Replacement.Text = "?"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " wykrzyknik"
        .Replacement.Text = "!"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " cudzysłów"
        .Replacement.Text = """"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " zamknij nawias"
        .Replacement.Text = ")"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
      Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "trzykropek"
        .Replacement.Text = "..."
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = " nawias "
        .Replacement.Text = "("
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " enter"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

1 个答案:

答案 0 :(得分:1)

提示是由wdFindAsk引起的。您的代码也可以大大简化。试试:

Sub GoogleVoice()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Text = " przecinek"
  .Replacement.Text = ","
  .Execute Replace:=wdReplaceAll
  .Text = " kropka"
  .Replacement.Text = "."
  .Execute Replace:=wdReplaceAll
  .Text = " dwukropek"
  .Replacement.Text = ":"
  .Execute Replace:=wdReplaceAll
  .Text = "myslnik"
  .Replacement.Text = "-"
  .Execute Replace:=wdReplaceAll
  .Text = " znak zapytania"
  .Replacement.Text = "?"
  .Execute Replace:=wdReplaceAll
  .Text = " wykrzyknik"
  .Replacement.Text = "!"
  .Execute Replace:=wdReplaceAll
  .Text = " cudzysłów"
  .Replacement.Text = """"
  .Execute Replace:=wdReplaceAll
  .Text = " zamknij nawias"
  .Replacement.Text = ")"
  .Execute Replace:=wdReplaceAll
  .Text = "trzykropek"
  .Replacement.Text = "..."
  .Execute Replace:=wdReplaceAll
  .Text = " nawias "
  .Replacement.Text = "("
  .Execute Replace:=wdReplaceAll
  .Text = " enter"
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub