script not opening MS Word

Discussion in 'PHP' started by mayuroak, Apr 25, 2007.

  1. #1
    <?
    //$filename="http:\\192.168.0.37\SagnikResumeFull.doc";
    $word = @new COM("word.application") or die("Unable to instantiate Word");
    $word->Documents->Open($filename);
    $new_filename = substr($filename,0,-4) . ".txt";
    // the '2' parameter specifies saving in txt format
    $word->Documents[1]->SaveAs($new_filename,2);
    $word->Documents[1]->Close(false);
    $word->Quit();
    $word->Release();
    $word = NULL;
    unset($word);

    $fh = fopen($new_filename, 'r');
    // this is where we exit Hell
    $contents = fread($fh, filesize($new_filename));
    fclose($fh);
    unlink($new_filename);
    ?>

    why this script is not opening the word application. Do we need to install COM.
     
    mayuroak, Apr 25, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you getting any errors?

    Take a look:

    http://builder.com.com/5100-31-5077752.html
    Code (markup):
     
    MMJ, Apr 25, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Are you on a windows server? What errors do you get?
     
    nico_swd, Apr 25, 2007 IP
  4. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Let's suppose you are running on win server ...


    why the filename is commented ?

    //$filename="http:\\192.168.0.37\SagnikResumeFull.doc";
     
    commandos, Apr 25, 2007 IP