Subscribe via Email

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

Create a word document

$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
//add some text to the document
$word->Selection->TypeText(“this is some sample text in the document”);
//save the document as sampleword.doc
//close word
//free object resources
$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>