terro Posted November 3, 2015 Posted November 3, 2015 Hi,I discoverd autoit, I'm not a programmer and I get stuck understanding the way word.au manage the sentences in Word 2010.1) I need to start setting the cursor at the beginning of the Word document.Then use a kind of loop on the entire documentselect the first sentence with 6 words display a message "OK" (the only way I found is unelegant key sequence F8+ F8+F8.)then get and select the next sentence with six words and display "OK".2) how to remove the "double or triple carriage return" in the same documentHere my piece of code#include <MsgBoxConstants.au3>#include <Word.au3>; Create application objectLocal $oRange, $oWord = _Word_Create(),$oRangeFound, $oRangeTextIf @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended); Open the test documentLocal $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.docx", Default, Default, True)If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _ "Error opening '.\Extras\Test.docx'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)For $I = 1 To 235 Step 1 ; sentence counter $oRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, $I, Default,0)If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _ "Error setting/expanding range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)$oRange.SelectSend("{F8}") ;X3 (F8) allows to select a sentenceSend("{F8}")Send("{F8}")sleep(400) ; MsgBox(0, "", "OK")Send("{ESCAPE}") ; free the sentence selectionSend("^{DOWN}") ; get to the next sentenceNextThank you for your help.
water Posted November 3, 2015 Posted November 3, 2015 Scene 1 in the example script in the help file for function _Word_DocRangeSet should show you how to get statistics. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
terro Posted November 3, 2015 Author Posted November 3, 2015 Thanks water,Is there a way to detect and skip any table (containing some text) using $oRange.The aim is to select sentences (avoiding any text in table cells).Thank you
water Posted November 4, 2015 Posted November 4, 2015 You could process all tables and count words/sentences. Then process the whol document and count word/sentences. Subtract the results from the tables part for the final result. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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