#AutoIt3Wrapper_run_debug_mode=N ;Y/N use this to debug in console window <--- LOOK #include #include #include #include #include #include $sMarker = "[[insert:" ;we use case insensitive for the search $eMarker = "]]" ;end marker $version = "v3c" ;v3c - really cut down for testing, NO error checking to speak of, NO variable scope declarations $oWord = _Word_Create() ;Create application object $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Test for Range Copy v1a.docx", Default, Default, True) ;put test file in same directory as script If @error Then Exit MsgBox($MB_SYSTEMMODAL, "ERROR", "Error opening file = '" & @ScriptDir & "\Test for Range Copy v1a.docx" & "'" & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $aFilenames[310][2] ;hard coded for test a little larger ;set up an array for filenames; put $count in [0][0], col[0]=marker range, col[1]=extended range $count = 0 $oRangeFound = _Word_DocFind($oDoc, $sMarker, 0, Default, True) ;search entire doc, use found range from last call, move toward end of document If $oRangeFound = 0 Then MsgBox($MB_SYSTEMMODAL, "Information", $sMarker & " count = " & $count &@CRLF& "No markers found") Exit Else $count = $count + 1 $aFilenames[0][0] = $count $oRangeFound.Copy ;v3c copy to clipboard $clip = ClipGet() $aFilenames[$count][0] = $clip $oRangeExtended = _Word_DocRangeSet($oDoc, $oRangeFound, $wdCharacter, 0, $wdParagraph, 1) ;extend range to and including paragraph character - leave $$oRangeFound alone $oRangeExtended.Copy ;v3c copy to clipboard $eclip = ClipGet() $aFilenames[$count][1] = $eclip EndIf ;now let's find the rest While ($oRangeFound =_Word_DocFind($oDoc, $sMarker, 0, $oRangeFound, True)) <> 0 ;v1c ;search entire doc, use found range from last call, move toward end of document $count = $count + 1 $aFilenames[0][0] = $count $oRangeFound.Copy ;v3c copy to clipboard $clip = ClipGet() $aFilenames[$count][0] = $clip $oRangeExtended = _Word_DocRangeSet($oDoc, $oRangeFound, $wdCharacter, 0, $wdParagraph, 1) ;extend range to and including paragraph character - leave $$oRangeFound alone $oRangeExtended.Copy ;v3c copy to clipboard $eclip = ClipGet() $aFilenames[$count][1] = $eclip WEnd MsgBox($MB_SYSTEMMODAL, "Information", "The count of '" & $sMarker & "' markers found in the file (count) = " & $count & @CRLF & "Look for dropped entries in either column.") _ArrayDisplay($aFilenames, "[0][0] has count, $aFilenames col[0] $sMarker range, col[1] extended range") Exit