From: poon dot fung at gmail dot com Operating system: Windows XP PHP version: 5.2.0 PHP Bug Type: COM related Bug description: Error passing Word macro arguments
Description: ------------ I can call a Word macro without any argument ok. But when I pass a string arguement to a Word macro, I get the following exception. Source: Unknown Description: Unknown I discovered the following problem: 1. It works when a macro does not have argument. The macro can be in the default macro file "Module/NewMacros" or other module file such as "Module/MyMacros". 2. It works when a macro has one or more arguements when the macro is in default macro file "Module/NewMacros". It does not work when the same macro is copied to a different module file such as "Module/MyMacros". Reproduce code: --------------- <?php // C:\testme.doc is any Word document $word = new COM('Word.Application') or die('Start Word automation failed.'); $word->Documents->Open('c:\testme.doc'); $arg1 = 'Some value'; // First test --> This works fine //$word->Application->Run('phptest1'); // Second test --> This works fine //$word->Application->Run('phptest2', $arg1); // Third test --> This works fine //$word->Application->Run('phptest3', $arg1, $arg1); // Forth test --> This works fine //$word->Application->Run('Normal.MyMacros.phptest1'); // Fifth test --> FAILED $word->Application->Run('Normal.MyMacros.phptest2', $arg1); // Sixth test --> FAILED //$word->Application->Run('Normal.MyMacros.phptest3', $arg1, $arg1); $word->Quit(); $word = null; /* // Word macros Sub phptest1() End Sub Sub phptest2(arg1 As String) End Sub Sub phptest3(arg1 As String, arg2 As String) End Sub */ ?> Expected result: ---------------- To run the test: 1. Create a dummy Word document C:\testme.doc". 2. Copy the three dummy procedures (phptest1, phptest2 and phptest3) to Word's macro file "Normal/Module/NewMacros". 3. Create a new macro file "Normal/Module/MyMacros" and paste the same three procedures in it. 4. Uncomment the line after each test case and keep lines for other test cases commented. 5. Run each test case. Case 1-4: No output. Just finish without error. Case 5-6: Show the error below. Actual result: -------------- PHP Fatal error: Uncaught exception 'com_exception' with message 'Source: Unknown Description: Unknown' in C:\bug2.php:21 Stack trace: #0 C:\bug2.php(21): variant->Run('Normal.MyMacros...', 'Some value') #1 {main} thrown in C:\bug2.php on line 21 -- Edit bug report at http://bugs.php.net/?id=39930&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39930&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39930&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39930&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39930&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39930&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39930&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39930&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39930&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39930&r=support Expected behavior: http://bugs.php.net/fix.php?id=39930&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39930&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39930&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39930&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39930&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39930&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39930&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39930&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39930&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39930&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39930&r=mysqlcfg