#6774
Support 1
Participant

    I believe that using the selection object (.ActiveDocument) in Word is unreliable. Also, neither VBScript nor Formativ know the Word constant wdReplaceAll.

    The following code sample should be a useful alternative.

    Advansys Support

    Const wdReplaceAll = 2
     
    '-------------------------------------------------------------------------------
    ' Mainline processing
    '-------------------------------------------------------------------------------
    Sub Main(Client, GWEvent)
     
      dim oRange
      dim oWordObj
     
      On error resume next
     
      Set oWordObj = CreateObject("Word.Application")
     
      if oWordObj is nothing then
        exit sub
      end if
     
      oWordObj.Documents.open("c:temptest.doc")
      oWordObj.visible = true
     
      Set oRange = oWordObj.Documents(1).Content
     
      if oRange is nothing then
        exit sub
      end if
     
      Call oRange.Find.Execute("%1",FALSE,TRUE, FALSE,,,TRUE,FALSE,FALSE,"Argl",wdReplaceAll)
     
      set oRange = nothing
      set oWordObj = nothing
     
    End Sub