I did it now :) i read about word typelib, but the including didnt work so I read out all the constants and defined them myself. I dont wanna use LibreOffice if i dont have to because creating the docs with word, then analyse them with libre and then convert them with word are too many components that can go wrong i think.
So here is my function. I use it on every created document before merging:
public function printDuplex($file){
$word=new COM("Word.Application") or die("Cannot start MS Word");
$word->visible = 0 ;
//6 = wdStory VB (end of document)
define('endOfPage', 6);
//(2 = wdStatisticPages VB)
define('pageCount', 2);
//open File
$word->Documents->Open($file);
// get pagecount
$count = $word->ActiveDocument->ComputeStatistics(pageCount);
//If odd pagecount
if($count%2 > 0){
//6 = wdStory VB (end of document)
//go to end of document
$word->Selection->EndKey(endOfPage);
//add page
$word->Selection->InsertBreak();
}
//save document
$word->Documents[1]->SaveAs($file);
$word->Quit( );
$word = null;
}
Thank you for your help you sat me on the right track :)
regards