potters 0 Posted October 3, 2011 Hi, I am brand new to programming and AutoIt. I know this is totally stupid, but I am having an issue with a script I am trying to write (just to practice). I can get a blank word doc to open but I can't get the text to send. I've tried a couple of different ways... HELP??? #ce ---------------------------------------------------------------------------- ; Script Start #include <Word.au3> $oWordApp = _WordCreate () $oDoc.Send("The quick brown fox jumps over the lazy dog.") $oDoc.WinWaitActive $oDoc.Send = ("The quick brown fox jumps over the lazy dog. {enter}") $oDoc.WinWaitActive("Untitled-$oWordApp") $oDoc.WinWaitActive("Untitled-$oWordApp") $oDoc.Send = ("The quick brown fox jumps over the lazy dog. {enter}") $oDoc.WinWaitActive("Untitled-$oWordApp") $oDoc.WinWaitActive("Untitled-$oWordApp") $oDoc.WinClose("Untitled-$oWordApp") $oDoc.WinWaitActive("$oWordApp", "Do you want to save") $oDoc.Send("!n") _WordQuit ($oWordApp, -1) Share this post Link to post Share on other sites
BillLuvsU 8 Posted October 3, 2011 I'm not familiar with word.au3 (I don't use MS Office), but you seem to have several errors in your programming "grammar" (referred to as syntax). I would suggest going through Welcome To AutoIt 1-2-3, it can be found in the examples section of the forum, right at the top (It's a sticky). [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Share this post Link to post Share on other sites
water 2,392 Posted October 3, 2011 (edited) You are mixing the Word COM object and AutoIt functions. It doesn't work this way. You create an application object by _WordCreate(). What's needed next is a function call to create the document object ($oDoc). Then you can enter text. I check if I can find a useful example. Edit: Something like this should work. If you have problems creating the doc, please try the latest Beta version of AutoIt. #include <word.au3> $oWordApp = _WordCreate(@ScriptDir & "\Test.doc") $oDoc = _WordDocGetCollection($oWordApp, 0) $oDoc.Range.InsertAfter("Test Text") ;_WordDocSave($oDoc) ;_WordQuit($oWordApp) Edited October 3, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
JoHanatCent 13 Posted October 3, 2011 I agree with all of the above ! To use the OP example: #include <Word.au3> Opt("WinWaitDelay", 250) $oWordApp = _WordCreate("Temp.doc");Create file it is easier for a consistant Title $yes = 0 While $yes = 0 ;Force focus ======== V $Yes = WinActivate("Temp.doc");<<<< === Make sure this is what you expect in the Title! Sleep(500); Pause script for A while wend Send("The quick brown fox jumps over the lazy dog.") Send("{enter}") Sleep(500); Pause script for A while Send("The quick brown fox jumps over the lazy dog.") Send("{enter}") Sleep(500); Pause script for A while WinClose("Temp.doc");<<<< === Make sure this is what you expect in the Title! WinWaitActive("Microsoft "); The actual Title not the message !!!! Send("!n") _WordQuit($oWordApp, -1); This will produce an error because you already closed the window with WinClose !!!!!!! Share this post Link to post Share on other sites