Hello, please sign in or register
You are here: Home

COM MS Office Edit MS Word

COM is a Microsoft product which lets applications like PHP connect to functions like reading, editing and printing, WORD, Excel documents. However i could not find much information on it I have created this script which will read the text content of a MS Word documnet(.doc). Including text within text box. Enjoy!

View written text content of .DOC file

[CODE=php]
<?php
// Connect to COM
$word = @new COM( "word.application" ) or die( "Unable to instanciate Word" );
// open file
$word->Documents->Open($file);
 // view main content
$content = $word->ActiveDocument->Content->Text;
// Get content from textboxes
for($i = 1; $i <= $word->ActiveDocument->Shapes->Count; $i++){
$content .= chr(13).$word->ActiveDocument->Shapes[$i]->TextFrame->TextRange->Text;
}
// Clean up content
$content = str_replace(chr(7), "", $content);

// removes table carriage returns
$content = trim($content, chr(13));

// trims n carriage returns at the start and end of doc
$content = trim($content, chr(10)); // trims n carriage returns at the start and end of doc
$content = trim($content, chr(9)); // trims t carriage returns at the start and end of doc
$content = nl2br($content); // Replace n carriage returns with breaks
// Could have instead used
str_replace(chr(13), " ", $content);
//closing word
$word->Quit();
//free the object
$word->Release();
$word = null;
return $content;
}
?>
[/CODE]

For linux, I found some links to implement another time.

Comments

guoyanying
But the replica watches sentry reebok shoes knew abercrombie and fitch uk his
Created 07/10/15
1015maoqiuyun
coach outlet online, http://www.coachoutletonline-store.us.com/
Created 15/10/15
ninestab123
ninest123 One canada goose pas cher gucci outlet thing
Created 21/07/16
michael kors factory outlet
adidas nmd pandora bracelet
Created 16/05/17
Title*
Comment

Prove you are not a robot

To prove you are not a robot, please type in the six character code you see in the picture below
Security confirmation codeI can't see this!
Contact
Name*
Email never shown*
Home Page

Author

Andrew Dodson
Since:Feb 2007

Comment | flag

Categories

Bookmark and Share