dans le cadre d'un projet en only php , je dois inserer une image dans un document word, apres diverxs lectures et reception du code vb pour l'action encourure , je n'arrive pas a le transposer en php :
Code : Tout sélectionner
/**
code vb
Selection.InlineShapes.AddPicture
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.TypeText "Here is a sentence preceding the picture."
objSelection.TypeParagraph()
Set objShape = objSelection.InlineShapes.AddPicture("C:\Scripts\Chart.gif")
objSelection.TypeParagraph()
objSelection.TypeText "Here is a sentence following the picture."
objSelection.TypeParagraph()
**/Code : Tout sélectionner
$word = new COM("word.application") or die("Unable to instantiate Word");
//2. specify the MS Word template document (with Bookmark TODAYDATE inside)
$template_file = "C:/reminder.doc";
//3. open the template document
$word->Documents->Open($template_file);
//4. get the current date MM/DD/YYYY
$current_date = date("m/d/Y");
//5. get the bookmark and create a new MS Word Range (to enable text substitution)
$bookmarkname = "TODAYDATE";
$word->InlineShapes->AddPicture("C:/images2.jpeg");
//$Image=$word->Shapes;
//$Image->AddPicture("C:/images2.jpeg");
//7. save the template as a new document (c:/reminder_new.doc)
$new_file = "c:/reminder_new.doc";
$word->Documents[1]->SaveAs($new_file);
//8. free the object
$word->Quit();
$word->Release();
$word = null;
unset ($word);
merci d'avance