Page 1 of 1

Microsft Word Files & PHP

Posted: Mon Nov 10, 2003 6:47 am
by igoy
So it's not everyday someone will come up to you and ask something that you are not sure if possible or not, Your logic says it could be done but you are not sure if it's really so and how.

one of my friend asked me if I can make a program for him in PHP (since I always keep boasting about PHP) which can read microsoft word files (in this case word 97 format) and check for few things in content (some conditions about double space after full stop and so) and return information regarding.

that is, there is a file called page57.doc, now he want to read that file in PHP and run few conditions like to check if there are double spaces after each fullstop. If anywhere in that it occurs that there is single space or no space after a full stop then it should return an error stating "there is a condition 1 error at line no. 10" .... and so on for each error.

now checking and returning is not a big deal if can read the content of word file as it is shown in MSword.

Now what I would like to know from you all is,

Can I read or fetch text from MS word file using PHP?

and

what are the other scopes I can have once I could read the MS word file ?

I have been opening my big mouth so much about PHP, now it's not only the matter of my reputation, but also of PHPs.... ;)

Posted: Mon Nov 10, 2003 8:41 am
by JayBird
yes you can, but the first question you need to ask is what OS you are running the scripts on, as you can only do it on a Windows Box.

Mark

Posted: Mon Nov 10, 2003 8:46 am
by igoy
I'm really sorry for not mentioning the OS, as I thought it would be obvious ...

anyways...
If I take up this task I guess I would be running the program on
following config :

PIII 550 MHz sys with 128 MB ram,
windows 2000 professional with IIS 4
and PHP 4.2.3 or higher (whichever is required)

Thanks in Advance... :)

Posted: Mon Nov 10, 2003 8:50 am
by JayBird
here a little example of how to write to a word doc

Code: Select all

<?
$word=new COM("word.application") or die("Cannot start MS Word"); 
print "Loaded word version ($word->Version)\n"; 
$word->visible = 1 ; 
$word->Documents->Add(); 
$word->Selection->Typetext("This is a test");
?>
Then read the COM functions in the manual - http://se.php.net/manual/en/ref.com.php

You will also have to visit microsofts site to find out how to do all the writing and reading of the files. I have only used it for writing, but anything the user can do, you can do.

Mark

Posted: Mon Nov 10, 2003 8:53 am
by JayBird

Posted: Mon Nov 10, 2003 8:56 am
by igoy
God Damn it... But of course... the "COM" ...

bech... you really are the PIMP DADDY ;)