Page 1 of 1
Get content from ms word
Posted: Tue Mar 16, 2004 4:11 am
by p_h_p
Hi,
I want to create php page that gets all the content from ms word file. It means i want to publish word content directly into php page...Can someone please help me...thanks....
Posted: Tue Mar 16, 2004 6:13 am
by JayBird
ARe you running on a windows or unix sever?
Only possible on windows using the COM functions
Mark
Posted: Tue Mar 16, 2004 11:37 pm
by p_h_p
I running on windows, then i have config the COM in the php.ini...But may i know how the codes look like? thanks.
Posted: Wed Mar 17, 2004 1:38 am
by m3mn0n
Posted: Wed Mar 17, 2004 4:07 am
by p_h_p
Code: Select all
<?
$input = "Appendix_5___Interim_Report.doc";
$word = @new COM("word.application") or die("Unable to instantiate Word");
print "Loaded Word, version {$word->Version}\n<br>";
$word->Visible = 1;
print "Set Word To Visible<br>";
$word->Documents->Open($input);
print "Opened $input<br>";
$word->Activate;
print "Activated Word<br>";
print "Editing Fields<br>";
$Field = $word->ActiveDocument->Fields(1);
$fieldData = $Field->Result;
$fieldData->Text = "Testing";
// Print the document.
$word->Printout();
// closing word
$word->Quit();
// free the object
$word->Release();
$word = null; ?>
I have try tis code but it take v.long to load....is there aniting wrong with the codeS?thank..
Posted: Wed Mar 17, 2004 4:13 am
by JayBird
No nothing wrong with it, it's just that it takes a long time to load Word.
Mark
Posted: Wed Mar 17, 2004 4:48 am
by p_h_p
But now the problem is it only load half way and it stop already...
Posted: Wed Mar 17, 2004 5:58 am
by m3mn0n
How large is the final your loading?
Posted: Wed Mar 17, 2004 6:06 am
by alucard
Check your max allowable execution time for a script on php.ini
Posted: Wed Mar 17, 2004 8:25 am
by p_h_p
The word file is only 20kb, and ytdae i have try it oso...it did not load for so long but have errors on
1) $Field = $word->ActiveDocument->Fields(1);
2) $word->Printout();