Инструменты пользователя

Инструменты сайта


programming:php:word.com-merge-documents

Merge Документов с отслеживанием изменений (рецензированием)

$file3  = 'c:\\inetpub\\dev_v9\\stuff\\private\\doc_parser\\source_1.doc';
$file4  = 'c:\\inetpub\\dev_v9\\stuff\\private\\doc_parser\\source_2.doc';


echo parse_docx($file3, $file4); 


function parse_docx($filename, $filename2){
     $comObject = new COM("Word.Application");
     if (!$comObject)
     {
         $this->lastError = "COM object of microsoft word cannot be found. Check COM permissions or Office install";
         return false;
     }

    // Open doc in Word
    echo "Open:";
    echo $filename;
    echo "\n";
    if (!$comObject->Documents->Open( addslashes($filename) ))
    {
        echo "can`t open1\n";
        $comObject->Quit(0);     // Always quit ! otherwise msword.exe will stay
        return false;
    }

    echo "Open2:";
    echo $filename2;
    echo "\n";
    if (!$comObject->Documents->Open( addslashes($filename2) ))
    {
        echo "can`t open2\n";
        $comObject->Quit(0);     // Always quit ! otherwise msword.exe will stay
        return false;
    }



    echo "\nloaded file\n";

    $comObject->MergeDocuments($comObject->Documents[2], $comObject->Documents[1]);



    //$comObject->ActiveDocument;
    echo $save_to = 'c:\\inetpub\\dev_v9\\stuff\\private\\doc_parser\\____5_'.time().'.docx';
    $comObject->Documents[1]->SaveAs($save_to);
    //$comObject->Documents[1]->SaveAs($save_to , 2);


    echo "Parse\n";
    $comObject->ActiveDocument->Close();
    $comObject->Quit(0);
    return $return;
}

programming/php/word.com-merge-documents.txt · Последнее изменение: 2017/03/27 11:26 — artur

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki