PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
p_h_p
Forum Newbie
Posts: 7 Joined: Tue Mar 16, 2004 4:11 am
Post
by p_h_p » Tue Mar 16, 2004 4:11 am
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....
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Mar 16, 2004 6:13 am
ARe you running on a windows or unix sever?
Only possible on windows using the COM functions
Mark
p_h_p
Forum Newbie
Posts: 7 Joined: Tue Mar 16, 2004 4:11 am
Post
by p_h_p » Tue Mar 16, 2004 11:37 pm
I running on windows, then i have config the COM in the php.ini...But may i know how the codes look like? thanks.
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Wed Mar 17, 2004 1:38 am
p_h_p
Forum Newbie
Posts: 7 Joined: Tue Mar 16, 2004 4:11 am
Post
by p_h_p » Wed Mar 17, 2004 4:07 am
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..
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Mar 17, 2004 4:13 am
No nothing wrong with it, it's just that it takes a long time to load Word.
Mark
p_h_p
Forum Newbie
Posts: 7 Joined: Tue Mar 16, 2004 4:11 am
Post
by p_h_p » Wed Mar 17, 2004 4:48 am
But now the problem is it only load half way and it stop already...
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Wed Mar 17, 2004 5:58 am
How large is the final your loading?
alucard
Forum Newbie
Posts: 3 Joined: Wed Mar 17, 2004 5:49 am
Post
by alucard » Wed Mar 17, 2004 6:06 am
Check your max allowable execution time for a script on php.ini
p_h_p
Forum Newbie
Posts: 7 Joined: Tue Mar 16, 2004 4:11 am
Post
by p_h_p » Wed Mar 17, 2004 8:25 am
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();