MATLAB: How to use activex to search Word documents for a phrase and delete the document

activexactxserverdelete filefor loopif statementmicrosoft wordsearch documentword

I would like to search through ~100 Microsoft Word documents for a specific phrase (survey), if the document contains (survey) anywhere within the document, I would like to delete the document.
Code at this link works to create a word document, however I am trying to pick it apart to search an existing document.
Then I would need a 'for loop' to cycle through the ~100 documents and delete the document if (survey) is found with an 'if statement'.

Best Answer

When all you have is a hammer everything looks like a nail!
Rather than trying to work out how to automate word from matlab, why not simply use the search feature of windows file explorer. Put survey in your search box and restrict the search to word documents. When the result are returned, select all, press delete. done.