Zieq Posted January 17, 2014 Share Posted January 17, 2014 (edited) Hello, I am implementing a repetitive process of my project through autoit and I have a workflow in which i am having two word file. 1.In the first file i have a table and i want to type text in 1st row, 2nd column and i want to copy(Screenshot taken by PrtSc) from clipboard to end of page, and now i want to copy all content to clipboard and close this file without saving. 2. And in second doc file i want to copy all data from clipboard to end of file and save it before closing. i want to do these 1,2 operation repeatedly with HotKeySet().. Below is the code i am writing, its executing for the first time but not executing second time. Please help me. thanks in advance. Func Copy() $oword = ObjCreate("Word.Application") $oword.visible = True $oword.Documents.open("Evidence_Copy.docx") $oword.Selection.Move($wdCell,1) ;moving to another cell $oword.Selection.TypeText("1") $oword.Selection.Move($wdSection,1) ;moving to end of page $oword.Selection.Paste() ;pasting from clipboard $oword.Selection.WholeStory ;selecting whole document $oword.Selection.Copy() ; copy all content $word = ObjCreate("Word.Application") $word.visible = True $word.Documents.open("Evidence.doc") $word.Selection.Move($wdSection,1) ;end of page $word.Selection.Paste() $oword.Documents.Close($WdDoNotSaveChanges) $oword.Application.Quit() $word.Documents.Close($wdSaveChanges) $word.Application.Quit() EndFunc Edited January 17, 2014 by Zieq Link to comment Share on other sites More sharing options...
l3ill Posted January 17, 2014 Share Posted January 17, 2014 (edited) Hi Zieq, and welcome to the forums ! This is only the function, the execute part is missing, which is where you said the problem was... Bill Please post the entire script and please use the Post Your Code instructions located in my sig Edited January 17, 2014 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Zieq Posted January 17, 2014 Author Share Posted January 17, 2014 #include <Word.au3> #include <WordConstants.au3> HotKeySet("+^j", "Copy") Func Copy() $oword = ObjCreate("Word.Application") $oword.visible = False $oword.Documents.open("Evidence_Copy.docx") $oword.Selection.Move($wdCell,1) $oword.Selection.TypeText("1") $oword.Selection.Move($wdSection,1) $oword.Selection.Paste() $oword.Selection.WholeStory $oword.Selection.Copy() $word = ObjCreate("Word.Application") $word.visible = True $word.Documents.open("Evidence.docx") $word.Selection.Move($wdSection,1) $word.Selection.Paste() $word.Application.Save() $oword.Documents.Close($WdDoNotSaveChanges) $oword.Application.Quit() $word.Documents.Close($wdSaveChanges) $word.Application.Quit() EndFuncEvidence_Copy.docxEvidence.docx Link to comment Share on other sites More sharing options...
l3ill Posted January 17, 2014 Share Posted January 17, 2014 Okay, the 2 problems Ive found so far is that you need a while loop to keep the key set active. And you choice of Shortcut was colliding with the one in Scite. Try this and see if you get any further HotKeySet("+^5", "Copy") While 1 Sleep(1000) WEnd Good Luck ! Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
water Posted January 17, 2014 Share Posted January 17, 2014 AutoIt comes with a Word UDF that should help you to do what you want. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Zieq Posted January 17, 2014 Author Share Posted January 17, 2014 Thanks MVPs and dabbler I have another piece of code which executes with HotKeySet("^!j") $word = ObjCreate("Word.Application") $word.visible = True $word.Documents.open(@ScriptDir &"\"&"Evidence_Copy.docx") $word.Selection.Find.Execute("Step No.:") $word.Selection.Move(1,2) $word.Selection.TypeText($nCurrentStep) $word.Selection.Move($wdSection,1) $word.Selection.TypeText(@CRLF) $word.Selection.TypeText(@CRLF) $word.Selection.Paste() $word.Documents.Close($WdDoNotSaveChanges ) $word.Application.Quit() i have problem in $word.Selection.TypeText($nCurrentStep) my app gets closed when this line executes for 2nd time $ nCurrentStep is global, when i use this to show value in msgbox it shows correct value. Any help would be appreciated Thanks in advance. Evidence_Copy.docx Link to comment Share on other sites More sharing options...
water Posted January 17, 2014 Share Posted January 17, 2014 I suggest to add a COM error handler to your script. This will give you more detailed error information. Check function ObjEvent in the help file for an example. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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