Odilo60 Posted January 11, 2008 Share Posted January 11, 2008 Hi everyboby, I'm using AutoIt for a while and it does work out fine. Now I'm searching for a solution to add a image to a Word Document, like the UDF from Bid_Daddy. Textreplacement and ImageInsert is working, I trie to add a Image to a TextBox but it wont work I think its simple, but how to Thanks a lot Link to comment Share on other sites More sharing options...
BrettF Posted January 11, 2008 Share Posted January 11, 2008 If you didn't want to use the UDF (which is a way cooler and smarter way... ) you can copy the file to your clipboard (using _ClipPutFile) and then pasting it into an open word doc... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Odilo60 Posted January 11, 2008 Author Share Posted January 11, 2008 If you didn't want to use the UDF (which is a way cooler and smarter way... ) you can copy the file to your clipboard (using _ClipPutFile) and then pasting it into an open word doc... Hi Bert, I tried the UDF and it works fine.It should work like this:Read a Excel Sheet, create a Word Doc, replace some Text and add a image into a TextBox ( centered in the Doc)Add a image outside the TextBox is OK, but I can't get it into the TextBox Link to comment Share on other sites More sharing options...
Odilo60 Posted January 14, 2008 Author Share Posted January 14, 2008 Anybody a idea ?? Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 14, 2008 Moderators Share Posted January 14, 2008 I was working on this, but got sidetracked somehow. I'll see if I can come up with an example sometime today. Link to comment Share on other sites More sharing options...
Odilo60 Posted January 14, 2008 Author Share Posted January 14, 2008 I was working on this, but got sidetracked somehow. I'll see if I can come up with an example sometime today.Thanks in advance Big_Daddy Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 18, 2008 Moderators Share Posted January 18, 2008 Sorry it took me so long with the example, I got stuck on the text orientation problem. #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 ; Insert a picture into the textbox. _WordDocAddPicture($oDoc, @ScriptDir & "\test.jpg", False, True, $oRange) Link to comment Share on other sites More sharing options...
BrettF Posted January 19, 2008 Share Posted January 19, 2008 Ahhh! Brilliant! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Odilo60 Posted January 21, 2008 Author Share Posted January 21, 2008 SUPER Thanks a lot Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 2, 2008 Moderators Share Posted February 2, 2008 Ahhh! Brilliant!Thanks!SUPER Thanks a lot :)You're welcome, glad I was able to help. Link to comment Share on other sites More sharing options...
linum Posted January 22, 2010 Share Posted January 22, 2010 Sorry it took me so long with the example, I got stuck on the text orientation problem. #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 ; Insert a picture into the textbox. _WordDocAddPicture($oDoc, @ScriptDir & "\test.jpg", False, True, $oRange) Using this example, how can I remove the Text Box line from the text box? I know that in VBA I can write something like this to do the trick: Activedocument.Shapes("Text Box 1").Select Selection.ShapeRange.Line.Visible = msoFalse So, what is the line of code this example needs in order to acomplish this? Thank you... Link to comment Share on other sites More sharing options...
linum Posted January 28, 2010 Share Posted January 28, 2010 Using this example, how can I remove the Text Box line from the text box? I know that in VBA I can write something like this to do the trick: Activedocument.Shapes("Text Box 1").Select Selection.ShapeRange.Line.Visible = msoFalse So, what is the line of code this example needs in order to acomplish this? Thank you... Ok, I found the answer to my own question. To remove the textbox line frame, use the following line of code: $oTextbox.Line.Visible = False Hope this helps others... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now