Skip to main content
Cadet | Tier 2
August 18, 2022
Question

Microsoft Word Package - Bug Report

  • August 18, 2022
  • 4 replies
  • 358 views

For this package in the bot store: https://botstore.automationanywhere.com/bot/a2019-microsoft-word-package/p>

 

For each "Replace" action I use, it adds a carriage return to the end of the word document. Ive tried to disable all replace actions, and the carriage returns did not show. Then, I added 1 replace action, and a single return appeared at the bottom of the output word doc... when i added a 2nd replace action... 2 returns appeared at the bottom of the output word doc.

 

Is there any way to repair this or mitigate the issue?

    4 replies

    Andoni_1
    Navigator | Tier 3
    Navigator | Tier 3
    August 22, 2022

    From my experience that package is not working very well...I've tried to use it on a word document that included tables and it didn't replace anything. I coded a VBS script to workaround this, hope it helps

     

    Function GENERIC_TEXT_REPLACE(path,find_text,replace_text)

    ' Generic function to replace text in word document

    ' path(String): Full path of word document

    ' find_text(Array): Array of values to look For

    ' replace_text(Array): Array of values to replace

    Set objWord = CreateObject("Word.Application")

    objWord.Visible = False

     

    Set objDoc = objWord.Documents.Open(path)

    Set objSelection = objWord.Selection

     

    For i = 0 to UBound(find_text)

    FindText = find_text(i)

    MatchCase = False

    MatchWholeWord = true

    MatchWildcards = False

    MatchSoundsLike = False

    MatchAllWordForms = False

    Forward = True

    Wrap = wdFindContinue

    Format = False

    wdReplaceNone = 0

    ReplaceWith = replace_text(i)

    wdFindContinue = 1

    wdReaplaceAll = 2

     

    a = objSelection.Find.Execute(FindText,MatchCase,MatchWholeWord,MatchWildcards,MatchSoundsLike,MatchAllWordForms,Forward,Wrap,Format,ReplaceWith,wdReaplaceAll)

    Next

     

    'Save the doc

    objDoc.Save

    objDoc.Close

    objWord.Quit

     

    GENERIC_TEXT_REPLACE = "Success"

     

    End Function

    Cadet | Tier 2
    January 4, 2023

    I’m having exact same issues. Package itself is actually working good but the carriage return is a bit annoying. Did you find a solution to it?

    Cadet | Tier 2
    March 5, 2025

    @Andoni - how do you pass multiple parameters in the vb script?

    Cadet | Tier 2
    March 5, 2025

    @KinP We can pass multiple parameter in vb script is by passing the list variable. Now your list variable can have multiple values

    Function GENERIC_TEXT_REPLACE(Args)

     path=Args(0)

    find_text=Args(1)

     

    Now this index 0,1 depends on the sequence you have assigned it to list variable in AA. Please marked it as worked if it works for you.