2 Replies Latest reply on May 10, 2011 12:34 PM by RichardM0701

    Help! Macro Conversion

    RichardM0701 Level 1



      I am transitioning to InDesign and I have a macro that I need to convert to either VB or JS. The functionality is very simple. Document (A) is the document you want to check and have open. Document (B) is a list of about 1000 “not approved for use” words. If you have Document (A) open and you run the macro, it will check for the non-approved words found in Document (B). If there are any matches, the macro will highlight the words.


      Could someone tell me how much work I need to put into this to get the same functionality into InDesign? If someone has any suggestions to make this work a different way, I am very open for input.


      Thank you so much!


      See VB below:


      Sub CompareWordList()

          Dim sCheckDoc As String

          Dim docRef As Document

          Dim docCurrent As Document

          Dim wrdRef As Object


          sCheckDoc = "h:\Not_Approved_Words.docx"

          Set docCurrent = Selection.Document

          Set docRef = Documents.Open(sCheckDoc)



          With Selection.Find



              .Replacement.Font.Bold = True

              .Replacement.highlight = wdColorBlue

              .Replacement.Text = "^&"

              .Forward = True

              .Format = True

              .MatchWholeWord = True

              .MatchCase = False

             .MatchWildcards = False

          End With


          For Each wrdRef In docRef.Words

              If Asc(Left(wrdRef, 1)) > 32 Then

                  With Selection.Find

                      .Wrap = wdFindContinue

                      .Text = wrdRef

                      .Execute Replace:=wdReplaceAll

                      .MatchWholeWord = True

                      .Replacement.highlight = wdBlack

                  End With

              End If

          Next wrdRef




      End Sub

        • 1. Re: Help! Macro Conversion



          Make a new one. Just edit "FindChangeByList.jsx" on InDesign, save as another name, open the file "FindchangeList" on a folder FindChangeSupport, and save with another name too.

          In this file change like this:


          text {findWhat:"word"} {appliedCharacterStyle:"Bold"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:true, caseSensitive:true} Find all "word" and replace with Character Style "Bold".


          note for the values if it's true or false


          On the new file "FindChangeByList", change the line 102 with the name of the new "FindchangeList":


          var myFindChangeFile = myFindFile("/FindChangeSupport/newfindChangeList.txt")


          It's difficult by the repetition of lines but resolve the problem.



          • 2. Re: Help! Macro Conversion
            RichardM0701 Level 1

            Perfect! I was able to use your guidence and the help within the file to achive the results I was looking for. Thank you for your time!