如果您嘗試透過 COM 物件取得 Word 文件的屬性,您可能需要在您的腳本中定義一些常數,如下所示。
<?php
define('wdPropertyTitle', 1);
define('wdPropertySubject', 2);
define('wdPropertyAuthor', 3);
define('wdPropertyKeywords', 4);
define('wdPropertyComments', 5);
define('wdPropertyTemplate', 6);
define('wdPropertyLastAuthor', 7);
$word = new COM("word.application") or die ("無法初始化 MS Word 物件。");
$word->Documents->Open(realpath("Sample.doc"));
$Author = $word->ActiveDocument->BuiltInDocumentProperties(wdPropertyAuthor);
echo $Author;
?>