rosanchez Posted February 11, 2008 Share Posted February 11, 2008 Hi, I am a new user of AutoIt. I am trying to paste some .emf files into a word document. The pictures should be placed in determined places inte the document, However, I do not how to do this. I knot that it should be done with the _WordDocAddPicture function, along with the command $o_Range (which specifies the location where the picture will be placed in the text) Please, can someone help me? Thank you Link to comment Share on other sites More sharing options...
DjDeep00 Posted February 11, 2008 Share Posted February 11, 2008 From the help file... ; ******************************************************* ; Example 1 - Create a word window with a new blank document, ; then add some pictures to the document. ; ******************************************************* ; #include <Word.au3> $sPath = @WindowsDir & "\" $search = FileFindFirstFile($sPath & "*.bmp") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No images found") Exit EndIf $oWordApp = _WordCreate () $oDoc = _WordDocGetCollection ($oWordApp, 0) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $oShape = _WordDocAddPicture ($oDoc, $sPath & $file, 0, 1) If Not @error Then $oShape.Range.InsertAfter (@CRLF) WEnd ; Close the search handle FileClose($search) Link to comment Share on other sites More sharing options...
rosanchez Posted February 11, 2008 Author Share Posted February 11, 2008 Thank you DjDeep00. An additional question. How do you implement the command $o_Range in order to paste the figure in a desired place into the word document. From the help file... ; ******************************************************* ; Example 1 - Create a word window with a new blank document, ; then add some pictures to the document. ; ******************************************************* ; #include <Word.au3> $sPath = @WindowsDir & "\" $search = FileFindFirstFile($sPath & "*.bmp") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No images found") Exit EndIf $oWordApp = _WordCreate () $oDoc = _WordDocGetCollection ($oWordApp, 0) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $oShape = _WordDocAddPicture ($oDoc, $sPath & $file, 0, 1) If Not @error Then $oShape.Range.InsertAfter (@CRLF) WEnd ; Close the search handle FileClose($search) Link to comment Share on other sites More sharing options...
DjDeep00 Posted February 11, 2008 Share Posted February 11, 2008 All in the help file.... _WordDocAddPicture ( ByRef $o_object, $s_FilePath [, $b_LinkToFile = 0 [, $b_SaveWithDocument = 0 [, $o_Range = ""]]] ) $o_Range - Optional: The location where the picture will be placed in the text. "" = (Default) The picture is placed automatically Any range object Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 13, 2008 Moderators Share Posted February 13, 2008 Thank you DjDeep00. An additional question. How do you implement the command $o_Range in order to paste the figure in a desired place into the word document.See if this example is what you are looking for.Word - Find Text/Insert Image After Link to comment Share on other sites More sharing options...
rosanchez Posted February 13, 2008 Author Share Posted February 13, 2008 Hi Big Daddy, I was trying this script, it does not paste the pictures in the document. Can the pictures be pasted in some desired places. Thank you Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 14, 2008 Moderators Share Posted February 14, 2008 Yes they can, and the example above is one way of doing it. If you would like a more precise answer, give a more precise scenario. Link to comment Share on other sites More sharing options...
rosanchez Posted February 14, 2008 Author Share Posted February 14, 2008 Thanks Big Daddy, you were right, i did not realized that i had to change the name of the picture. One more question. Imagine that you have the following word document: Text Text Text Picture 1 Text Text Text Picture 2 Text Text Text Picture 3 Text Text Text Picture 4 And I want to make a script which pastes the pictures (1-4) in the selected places of the word document. This questions has one purpose. I am a research assistance, I calculate histograms and they change all the time. I use stata so i make a .do file which calculates the histograms and paste them intermediately in the word document. Thanks a lot, and I hope you can help me with this. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 14, 2008 Moderators Share Posted February 14, 2008 Two questions: Is the text already in the document? Can you provide an example .doc or .docx? Link to comment Share on other sites More sharing options...
rosanchez Posted February 14, 2008 Author Share Posted February 14, 2008 Is the text already in the document? Can you provide an example .doc or .docx? The text is already in the document, there is sufficient space into the document so the images can be pasted in it. what i want to make is an automatically update of the document. i do not understand the second question. Thanks again Link to comment Share on other sites More sharing options...
rosanchez Posted February 28, 2008 Author Share Posted February 28, 2008 Please Big Daddy, help!!!Hello Big Daddy, I do not know if you remember my question. I want to paste some pictures in a word document. Your previous script works well, but now I want to paste the pictures in a document which has the following format:TextPict 1.emfPict 2.emfTextPict 3.emfPict 4.emfPict 5.emfTextPict 6.emfPict 7.emfThe text was previously created, so every time I have new pictures I want to paste them automatically, because the pictures are updated very often. This is a .doc document.Thanks a lotLooking forward to hearing from youRaul Oscar SanchezUniversidad Nacional de La Plata Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 29, 2008 Moderators Share Posted February 29, 2008 I haven't had much time for AutoIt lately, so forgive me for forgetting about this thread. I started working on an example script for this, let me see if I can get it finished sometime today. Link to comment Share on other sites More sharing options...
rosanchez Posted February 29, 2008 Author Share Posted February 29, 2008 Thank you Big Daddy. I'll wait your response. Thanks again.- Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 4, 2008 Moderators Share Posted March 4, 2008 The attached file is the test environment I created for testing. In test.doc the .emf images are in reverse order 7-1, after running the script they will be in order 1-7. Test.zip Link to comment Share on other sites More sharing options...
rosanchez Posted March 4, 2008 Author Share Posted March 4, 2008 Thank very much Big Daddy. I really appreciatte your help. Thanks again Raul Sanchez Universidad Nacional de La Plata Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 4, 2008 Moderators Share Posted March 4, 2008 You're welcome! 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