Categories

Subscribe via Email

Enter your email address to subscribe and receive notifications of new content by email.

Create a word document

<?php
$word = new COM(“word.application”) or die (“couldnt create an instance of word”);
echo “loaded , word version{$word->version}”;
//bring word to the front
$word->visible = 1;
//open a word document
$word->Documents->Add();
//add some text to the document
$word->Selection->TypeText(“this is some sample text in the document”);
//save the document as sampleword.doc
$word->Documents[1]->SaveAs(“sampleword.doc”);
//close word
$word->Quit();
//free object resources
$word->Release();
$word = null;
?>

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBibSonomyDeliciousDiggDiigoSina WeiboWordPressBlogger PostShare

1 comment to Create a word document

  • karthikeyan

    when i tried to run the above script i get an
    Fatal error: Call to undefined method variant::SaveAs() in D:\wamp\www\karthik\refcode\writewordfile\writetoword.php on line 11.

    can you send me the correct code so that it will be of great help to me…

Leave a Reply

  

  

  


*

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>