yayh Posted March 13, 2007 Share Posted March 13, 2007 Dear all i tried this fine artical which guide hot to write php code to create ms office file using COM. http://web.informbank.com/articles/technology/php-office-documents.htm the problem that all the examples in this guide worked fine except the ms word example i am getting the following error: this is the output: I'm using MS Word 11.0 Fatal error: Call to a member function TypeText() on a non-object in C:\Inetpub\temp\index.php on line ... $word->Selection->TypeText("Hello, universe!"); // error is here ! please help i tried everything... ??? note: i am using windows server 2003 sbs and php 5 and office 2003 Link to comment https://forums.phpfreaks.com/topic/42473-php-com-with-ms-office/ Share on other sites More sharing options...
only one Posted March 13, 2007 Share Posted March 13, 2007 obviously theres a problem with the TypeText() function... ive never heard of it before but try this Type_Text() instead Link to comment https://forums.phpfreaks.com/topic/42473-php-com-with-ms-office/#findComment-206056 Share on other sites More sharing options...
yayh Posted March 13, 2007 Author Share Posted March 13, 2007 to see the funcation which can be call by the PHP & COM do the following open microsoft word (Alt+F11 to open Visual Basic Editor, F2 to open Object Browser). you can see that in the attached file and i also tried your suggestion and still the same error I'm using MS Word 11.0 Fatal error: Call to a member function Type_Text() on a non-object in C:\Inetpub\temp\index.php on line ... ************** ok i have another code which also give error and did know how to solve it ??? :-\ this the error : Loaded Word, version 11.0 Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> Command failed' in C:\Inetpub\temp\index.php:... Stack trace: #0 C:\Inetpub\temp\index.php(...): variant->Open('C:/inetpub/temp...') #1 {main} thrown in C:\Inetpub\temp\index.php on line ... <?php //1. Instanciate Word $word = new COM("word.application") or die("Unable to instantiate Word"); print "Loaded Word, version {$word->Version}\n"; //2. specify the MS Word template document (with Bookmark TODAYDATE inside) $template_file = "C:/Inetpub/temp/reminder.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 = "TODAYDATE"; $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 (c:/reminder_new.doc) $new_file = "C:/Inetpub/temp/reminder_new.doc"; $word->Documents[1]->SaveAs($new_file); //8. free the object $word->Quit(); $word->Release(); $word = null; ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/42473-php-com-with-ms-office/#findComment-206111 Share on other sites More sharing options...
yayh Posted March 18, 2007 Author Share Posted March 18, 2007 helloo help....... ??? Link to comment https://forums.phpfreaks.com/topic/42473-php-com-with-ms-office/#findComment-209790 Share on other sites More sharing options...
yayh Posted March 26, 2007 Author Share Posted March 26, 2007 again helloo help ...!!! Link to comment https://forums.phpfreaks.com/topic/42473-php-com-with-ms-office/#findComment-215209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.