SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: fread an .doc
-
Sep 30, 2003, 15:00 #1
fread and .doc
can i open and read (fopen and fread) a document .doc?
Regards from Spain.Last edited by marylin77; Sep 30, 2003 at 15:17.
-
Sep 30, 2003, 15:24 #2
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Umm....
Hardly used COM myself though your looking for something like this ?
PHP Code:...
$word = new COM('Word.Application');
//
if($word) {
$filename = 'c:/ms/word/invoicing.doc';
$accessed = $word -> Documents -> Open($filename);
.
.
-
Sep 30, 2003, 15:28 #3
ok thanks
-
Sep 30, 2003, 15:31 #4
- Join Date
- Apr 2003
- Posts
- 4,095
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Problems
Hello,
If all you want to do is open the Microsoft Word document, than Dr. Livingston's suggestion will work perfectly. But most people actually like to read or edit the document when they open it, and Word documents use a closed, proprietary format. Thus, you won't be able to read, edit, or manipulate the data in the document. I don't know if Microsoft is kind enough to help people out with this, but I doubt that there's another way.
Compuwhiz7
-
Sep 30, 2003, 15:42 #5
I am reading here:
http://es2.php.net/manual/en/ref.com.php
you wrote:
Thus, you won't be able to read, edit, or manipulate the data in the document.
///
do u mean is impossible to read a document.doc via php functions??
-
Sep 30, 2003, 16:17 #6
- Join Date
- Apr 2003
- Posts
- 4,095
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry!
Hello,
As far as I know, yes, it is impossible to read a Microsoft Word document using PHP. If, however, you could somehow convert the Word document into a plain text file (.Txt), then you could read, parse, and edit such a document.
Hope this helps...
Compuwhiz7
-
Sep 30, 2003, 16:22 #7
- Join Date
- Feb 2001
- Location
- New Zealand
- Posts
- 516
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well you could "read" it but it will mostly be gobble-de-goop (unreadable). Or in other words: open a .doc in Notepad and that's what you're going to get.
Oh no! the coots are eating my nodes!
-
Sep 30, 2003, 16:34 #8
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Do you know Visual Basic ?
I don't though maybe see if you can find anything more about the COM component over at Microsoft in relation to Visual Basic/PHP ?
--EDIT--
convert the Word document
-
Sep 30, 2003, 16:54 #9
thanks for all...All the comments had been very usefull for me Particularly,compuwhiz7's answer:
however, you could somehow convert the Word document into a plain text file (.Txt).
///How i can convert it?any idea?some routine made by someone :]?
PD: i do not know Visual Basic :[
Regards from Spain.
-
Sep 30, 2003, 18:03 #10
- Join Date
- Aug 2002
- Location
- Burpengary, Australia
- Posts
- 4,495
- Mentioned
- 0 Post(s)
- Tagged
- 1 Thread(s)
Course it can be done, in a round about way
Here is a link which explains it in details, and it's really pretty simple. Just have to convert it to HTML first.
-
Sep 30, 2003, 18:05 #11
Look at this:
PHP Code:<?php
// starting word
$word = new COM("word.application") or die("Unable to instanciate Word");
print "Loaded Word, version {$word->Version}\n";
//bring it to front
$word->Visible = 0;
//open an empty document
$word->Documents->Add();
//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("jo.doc");
//closing word
$word->Quit();
//free the object
$word->Release();
$word = null;
?>
$word->Documents[1]->SaveAs("jo.txt");
the file called jo.txt is unreadable.
Although If i open jo.doc with Microsoft Word and then i click in Save As and i write jo.txt (selecting .txt as type), then the file jo.txt is readable.
Curious...
-
Sep 30, 2003, 18:43 #12
thanks very much DJ_p@ckman...it is all right..now ( I convert the php file I want into an html file)
Regards from Spain.
Only one thing:
althoug I write:
PHP Code:$word->Visible = 0;
Bookmarks