Microsft Word Files & PHP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Microsft Word Files & PHP

Post 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.... ;)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post 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... :)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post by igoy »

God Damn it... But of course... the "COM" ...

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