I built a script that converts a Microsoft Word file to text and removes
common characters.  The text will then be stored in a database for searching.

The script below has been behaving a bit odd.  It worked this morning
but now all I get back is a blank screen and the text file it writes is
blank.  This worked all day yeasterday and this morning but now it
stopped working.  the script works fine if you manually save the Word
doc in the text format, but it wont write the text file.  I built the
COM code by creating a Macro in Word and then analyzing it in a VB editor.

Can anyone see what the problem might be?  It's driving me nuts.

<?php

// Filenames 
$wordDoc = "BHresume.doc"; 
$textDoc = "BHresume.txt";

// Perform Word Doc Conversion
$word=new COM("Word.Application") or die("There was a problem launching
MS Word"); 

$word->visible = 1 ; 
$word->Documents->Add(); 

// Open Word File
$word->Documents->Open->FileName[$wordDoc]->ConfirmConversions[False]->ReadOnly[False]->
AddToRecentFiles[False]->PasswordDocument[""]->PasswordTemplate[""]->Revert[False]->WritePasswordDocument[""]->WritePasswordTemplate[""]->Format["wdOpenFormatAuto"];

// Convert and save file as type=text
$word->ActiveDocument->SaveAs->FileName[$textDoc]->FileFormat["wdFormatText"]->LockComments[False]->Password[""]->AddToRecentFiles[True]->WritePassword[""]->ReadOnlyRecommended[False]->EmbedTrueTypeFonts[False]->SaveNativePictureFormat[False]->SaveFormsData[False]->SaveAsAOCELetter[False];

$word->Quit(); 

// Open the text doc
$fp = @fopen($textDoc,"ab+"); 

$fileText = fread($fp,8048); 
fpassthru($fp); 

// Array of common words
$commonWords= array("*"," the "," with "," but"," of "," every "," at
"," by "," and "," as "," their "," not", " an "," if "," or "," on ","
I "," in "," had "," on "," all "," a "," my ","
on "," up "," for "," each "," to "," etc "," that "," made ","
up","-",".",",",")","("); 

$finalString = $fileText; 

// Delete common words
for($i=0;$i<count($commonWords);$i++){ 
$finalString = str_replace($commonWords[$i]," ", $finalString); 
} 

// Print final string to screen
echo $finalString; 
?>


Thanks for any help!
Ron

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to