opening word document contailning macros using textarea
Posted
by avani-nature
on Stack Overflow
See other posts from Stack Overflow
or by avani-nature
Published on 2010-05-21T06:06:29Z
Indexed on
2010/05/21
6:10 UTC
Read the original article
Hit count: 172
php
Hai frnds i am avani here,actually 1.i amhaving one word document which contains macros i wann to open it in textarea.. 2.i am able to open the word document which is not containing macros 3.i am not able to open the document which contains macros 4.i am using below code 5.please do help me anyone i am thinking its some what impossible
{ //echo $aud; $filename = 'C:/xampp/htdocs/mts/sites/default/files/a.doc'; //echo $filename; if(isset($_REQUEST['Save'])){ $somecontent = stripslashes($_POST['somecontent']); // Let's make sure the file exists and is writable first. if (is_writable($filename)) {
// In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; }
// Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; }
echo "Success, wrote ($somecontent) to file ($filename) - Continue - ";
fclose($handle);
} else { echo "The file $filename is not writable"; } } else{ // get contents of a file into a string $handle = fopen($filename, "r"); $somecontent = fread($handle, filesize($filename)); $word = new COM("word.application") or die ("Could not initialise MS Word object."); $word->Documents->Open(realpath("$filename"));
// Extract content. $somecontent = (string) $word->ActiveDocument->Content;
//echo $somecontent;
$word->ActiveDocument->Close(false);
$word->Quit(); $word = null; unset($word); fclose($handle); } ?>
Edit file -------->
?>
© Stack Overflow or respective owner