PHP COM Object to Open Word 2013, Count Pages Not Wkg for .docm

I am using a PHP COM Object to Open a Word 2013 file and count pages. My code works great for .docx files but not for .docm files. I am using php 5.4 and IIS 7.5 in a Windows 2008 R2 environment. Any recommendations?

// Create an instance of the Word application
$word = new COM("word.application");
if ($word) {
    // Open the document
    $word->Documents->Open($file_dir . $filename);
			
    // Get the page count
    $pagecount = $word->Documents[1]->ComputeStatistics(2);
}

The solution was to turn off all macros like this before opening a file, which also disables security prompts:

$word->AutomationSecurity = 3;   // disable all macros in the documents being opened

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.