|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14516 can't write word file
Submitted: 2001-12-14 09:55 UTC Modified: 2004-08-03 04:19 UTC
From: ccy-chu at online dot sh dot cn Assigned:
Status: Closed Package: COM related
PHP Version: 4.0.6 OS: win2k server (chinese)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ccy-chu at online dot sh dot cn
New email:
PHP Version: OS:


 [2001-12-14 09:55 UTC] ccy-chu at online dot sh dot cn
when the code excuted on line:

$word->Documents[1]->SaveAs("Useless test.doc");

It print out "Invoke() failed: ....".
Nobody knows why.

code is here:
$word = new COM("word.application") or die("Unable to instanciate Word");
print "Loaded Word, version {$word->Version}\n";

//bring it to front
$word->Visible = 1;

//open an empty document

//do some weird stuff

$word->Documents[1]->SaveAs("Useless test.doc");

//closing word

//free the object
$word = null;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-14 10:08 UTC]
Changing Type.
 [2001-12-14 10:09 UTC]
Ah, btw, try latest 4.1.0 from

 [2001-12-14 10:10 UTC]
And try this:

$doc = $word->Documents[1];
$doc->SaveAs("Useless test.doc")
 [2002-01-05 16:50 UTC]
No feedback. Closing.
 [2004-08-03 03:53 UTC] ronnie dot shelton at digital-one-designs dot com
I am having the same problem:

Here is my code:

//1. Instanciate Word
$word = new COM("Word.Application") or die("Unable to instantiate Word");
//2. specify the MS Word template document (with Bookmark TODAYDATE inside)
$template_file = "d:/test.doc";
//3. open the template document
//4. get the current date MM/DD/YYYY
$current_date = date("m/d/Y");
//5. get the bookmark and create a new MS Word Range (to enable text substitution)
$bookmarkname = "reqNum";
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
//6. now substitute the bookmark with actual value
$range->Text = $current_date;
//7. save the template as a new document (D:\est\NEW_est.doc)
$newFile = "d:/test.doc";
$doc = $word->Documents[1];       //error here
$doc->Save("test.doc");           //error here
//8. free the object
$word = null;

I am trying some code from another site but I can't seem to get it to work properly...

I continue to get the same error: 

Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in D:\wwwroot\test.php on line 19

I tried everything and I am very new to PHP....

can someone help please....
 [2004-08-03 04:19 UTC]
d:/test.doc is not a win32 filename.
Use "d:\\test.doc" instead.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 19 05:05:44 2022 UTC