代码之家  ›  专栏  ›  技术社区  ›  Charles Stewart

“运行时错误5692”是什么意思?

  •  2
  • Charles Stewart  · 技术社区  · 14 年前

    错误“运行时错误5692”由 range .Find.Execute 在某些情况下,包括有时范围为空,有时使用格式错误的regex执行regex搜索。

    这个错误是什么意思?错误是否记录在任何地方?从我的无知立场来看,这是不可预测的。

    2 回复  |  直到 6 年前
        1
  •  2
  •   mechanical_meat    14 年前


    It appears

    Sub TextReplace()
    
        Dim oWord As Word.Application
        Dim oDoc As Word.Document
        Dim oFind As Find
    
        Set oWord = CreateObject("Word.Application")
        oWord.Visible = True
        Set oDoc = oWord.Documents.Add("C:\in.doc")
        Set oFind = oDoc.Range.Find
    
        oFind.Execute "foo", , , , , , , , , "bar", wdReplaceAll
    
        oDoc.SaveAs ("C:\out.doc")
        oDoc.Close
        oWord.Visible = False
    
    End Sub
    

        2
  •  3
  •   imjustmatthew    12 年前

    Sub ReplaceInDocument
      Dim wdReplaceAll
      'set the value for the replace "constant"
      wdReplaceAll = 2
      With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "^p"
        .Replacement.Text = "replacement text "
        .Forward = True
        .Wrap = 1
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
      'the Replace argument is the 11'th argument
        .Execute , , , , , , , , , , wdReplaceAll
      End With
    End Sub
    

    Sub ReplaceInDocument
      Dim wdReplaceAll
      'set the value for the replace "constant"
      wdReplaceAll = 2
      With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "^p"
        .Replacement.Text = "replacement text "
        .Forward = True
        .Wrap = 1
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
      'the Replace argument is the 11'th argument
        .Execute , , , , , , , , , , wdReplaceAll
      End With
    End Sub