#14516 [Csd]: can't write word file
| From: | wez@php.net | Date: | Tue, 03 Aug 2004 02:19:10 +0000 |
| Subject: | #14516 [Csd]: can't write word file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63973@lists.php.net to get a copy of this message | ||
ID: 14516
Updated by: wez@php.net
Reported By: ccy-chu at online dot sh dot cn
Status: Closed
Bug Type: COM related
Operating System: win2k server (chinese)
PHP Version: 4.0.6
New Comment:
d:/test.doc is not a win32 filename.
Use "d:\\test.doc" instead.
Previous Comments:
------------------------------------------------------------------------
[2004-08-03 03:53:09] ronnie dot shelton at digital-one-designs dot com
I am having the same problem:
Here is my code:
<?php
//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
$word->Documents->Open($template_file);
//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->Quit();
$word->Release();
$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....
------------------------------------------------------------------------
[2002-01-05 16:50:36] lobbin@php.net
No feedback. Closing.
------------------------------------------------------------------------
[2001-12-14 10:10:49] derick@php.net
And try this:
$doc = $word->Documents[1];
$doc->SaveAs("Useless test.doc")
------------------------------------------------------------------------
[2001-12-14 10:09:34] mfischer@php.net
Ah, btw, try latest 4.1.0 from http://php.net/downloads.php
Feedback.
------------------------------------------------------------------------
[2001-12-14 10:08:51] mfischer@php.net
Changing Type.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/14516
--
Edit this bug report at http://bugs.php.net/?id=14516&edit=1