Combining Two Scripts (1)
delete all duplicate lines of code
move all the variable statements to the beginning of the script
remove the line of code : Set myDocument = myInDesign.ActiveDocument
Combining Two Scripts (2)