ajit Posted September 25, 2010 Share Posted September 25, 2010 #include <Word.au3> $sPath1 = "C:\test1.doc" $sPath2 = "C:\test2.doc" $oWord = _WordCreate($sPath1, 0, 1) ; visible With $oWord.Selection .EndKey(6) .InsertBreak(7) .InsertFile($sPath2) EndWith Hi, I have a script which inserts text from one word document to another and it works fine. I have to provide paths to both documents though. My need is a bit different. I want to insert text from (document-2), which I can provide the path to, into another Word document (document-1) which is already opened by another program. I do not know how to achieve this. So I have one open document and another word document (path available) from where I want to put the text to the already open document. Two documents in C drive with some text in both doc files are needed to test the script. If there is a way to do this, please guide me. Regards Ajit Link to comment Share on other sites More sharing options...
taietel Posted September 25, 2010 Share Posted September 25, 2010 A "dirty" solution would be: #include <Word.au3> $sPath1 = @ScriptDir&"\test1.doc" $sPath2 = @ScriptDir&"\test2.doc" $oWord = _WordCreate($sPath1, 0, 1) ; visible $oDoc = _WordDocOpen($oWord,$sPath2) Send("^a") Sleep(200) Send("^c") _WordDocClose ($oDoc,0) Sleep(200) Send("^{END}") Send("^{ENTER}") Send("^v") If you have to insert text from doc[n] to doc[n-1] you can put the files into an array. M.I. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
ajit Posted September 25, 2010 Author Share Posted September 25, 2010 @taietel Thanks for your help. But I was just wondering if using "send method" on a continuous basis is okay, especially because there is always a risk of some other windows popping up disturbing its smooth functioning. Will SendKeepActive ( "title" [, "text"] ) work fine and just in case it is needed where do I place it in the code during multiple sends. Is it required for every Send command or just once would suffice? Regards Ajit Link to comment Share on other sites More sharing options...
taietel Posted September 25, 2010 Share Posted September 25, 2010 SendKeepAlive will do the job. Put it before start sending keys (see the help file). Once is enough! Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
ajit Posted September 25, 2010 Author Share Posted September 25, 2010 Thanks 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