Bonjour,
Je suis confronté à un soucis de mise en page avec Word.
En effet, je souhaite intégrer dans un fichier Word une image et le contenu d'un fichier texte.
Je voudrais que ma feuille soit en paysage, l'image à gauche et la partie texte à droite de mon image...
J'ai déjà "bricolé" quelque chose, mais soit l'image est avant ou bien après...
Si joint mon code:
► Afficher le texte
Code : Tout sélectionner
Func _CopyPictureAndTXTFileToWord()
;On créer l'instance
$oWord = _Word_Create()
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Impression courbe", "Erreur de création document Word." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;On ouvre le fichier Word
$oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Print.doc", Default, Default, True)
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Impression courbe", "Erreur d'ouverture 'Print.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;On définit l'orientation de la page (le cas présent Paysage)
$oDoc.PageSetup.Orientation = $wdOrientLandscape
$oRange = _Word_DocRangeSet($oDoc, -1)
;On ajoute l'image enregistrée sous @ScriptDir
_Word_DocPictureAdd($oDoc, @ScriptDir & "\PrintPicture.jpg", Default, Default, $oRange)
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Impression courbe", "Erreur de copie image." & @CRLF & " @error = " & @error & ", @extended = " & @extended)
;On ajoute le texte
Local $PFile = "Print.txt"
Local $asArray
If Not _FileReadToArray($PFile, $asArray) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error)
$oRange = _Word_DocRangeSet($oDoc, -1, -1, 0, -1)
$oTable = _Word_DocTableWrite($oRange, $asArray, 1)
EndFunc
Edit: En fait pour que mon image et mon texte soit juxtaposés, il faudrait que j'insère une zone de texte dans laquelle je viens mettre mon image... mais là je sais pas faire...

-> Faux, complètement faux, maintenant je sais ^^
Voici le code pour ceux que ça intéresse (provient du site anglais

):
► Afficher le texte
Code : Tout sélectionner
#include <Word.au3>
;WdTextOrientation
Const $wdTextOrientationHorizontal = 0
Const $wdTextOrientationUpward = 2
Const $wdTextOrientationDownward = 3
Const $wdTextOrientationVerticalFarEast = 1
Const $wdTextOrientationHorizontalRotatedFarEast = 4
Const $wdTextOrientationVertical = 5
Global $iLeft = 50, $iTop = 50, $iWidth = 200, $iHeight = 200
$sFilePath = @ScriptDir & "\Test.doc"
_WordErrorHandlerRegister()
$oWordApp = _WordCreate($sFilePath, 1)
$oDoc = _WordDocGetCollection($oWordApp, 0)
; Left, Top, Width, Height, Anchor
$oShape = $oDoc.Shapes.AddCanvas($oWordApp.PixelsToPoints($iLeft), $oWordApp.PixelsToPoints($iTop), $oWordApp.PixelsToPoints($iWidth), $oWordApp.PixelsToPoints($iHeight))
; Orientation, Left, Top, Width, Height
;~ $oTextbox = $oShape.CanvasItems.AddTextbox($wdTextOrientationHorizontal, 1, 1, $oShape.Width - 1, $oShape.Height - 1) ; I would expect this to work.
$oTextbox = $oShape.CanvasItems.AddTextbox($wdTextOrientationVertical, 1, 1, $oShape.Width - 1, $oShape.Height - 1) ; This does work however.
; Get the range object of the textbox.
$oRange = $oTextbox.TextFrame.TextRange
$oTextbox.Line.Visible = False
; Insert a picture into the textbox.
_WordDocAddPicture($oDoc, @ScriptDir & "\test.jpg", False, True, $oRange)
Merci.