Word Macro Powershell Script Broken

I wrote a script to check for Excel Macro’s that returns TRUE if a document contains a macro. I then wanted to reuse the code of Word Macro’s but its returning false even for documents I created a macro in (see code below). What am I doing wrong?

$word = new-object -comobject word.application
$doc = $word.documents.Open(“C:\Path\example.docm”)
Echo $doc.HasVBProject
$doc.Close()
$word.Quit()

Check that you actually created the macro in the document example.docm.

I was testing your code (which works fine) and it took me a few goes to realise that when I was creating the Word macro it was actually inserting it in normal.dotm, not in the test document. Use the Macros in: drop down to change where you’re putting the macro.