Servant Posted April 3, 2014 Share Posted April 3, 2014 I've check the Word user defined functions Reference but I can't find how to make this work... (First open or get the handle of an existing Microsoft Word document.) How can I perform a word count of each sentence and highlight any sentence with 31 or more words in red, and 21 to 30 words in blue? http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
water Posted April 3, 2014 Share Posted April 3, 2014 What have you tried so far? 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 Link to comment Share on other sites More sharing options...
Servant Posted April 3, 2014 Author Share Posted April 3, 2014 (edited) I'm still trying to get how to find a list of sentences to modify, I've also been to _Word_DocRangeSet but still no luck.. There are many ideas that are coming from my mind, such as how to store the objects of all the sentences in a Microsoft Word document, in an array but still haven't find a way.. Edited April 3, 2014 by Servant http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
water Posted April 3, 2014 Share Posted April 3, 2014 Did you have a look at the example script for _Word_RangeSet? "Move the start of the range to the next paragraph and extend the end by 2 ; words. Insert text before and after the range and display some statistics" Servant 1 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 Link to comment Share on other sites More sharing options...
Servant Posted April 4, 2014 Author Share Posted April 4, 2014 In this time the problem that I'm trying to solve is, how to highlight a set range in a MS Word document? I've came from many resources including Highlight Property, I even checked the source codes of the include files "Word.au3" and "WordConstants.au3" and I found out that you've rewritten them, and they don't have color enumeration.. I'd tried this: $oDoc.Options.DefaultHighlightColorIndex = 255 $oRange.Highlight = True And this: $oWord.Options.DefaultHighlightColorIndex = 255 $oRange.Highlight = True But no luck... http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
water Posted April 4, 2014 Share Posted April 4, 2014 (edited) Do you want to highlight the range (=set the color of the background) or just select the range (as you would do with mouse or keyboard)? Edited April 4, 2014 by water 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 Link to comment Share on other sites More sharing options...
Servant Posted April 4, 2014 Author Share Posted April 4, 2014 I know how to $oRange.Select .. Can you share some codes? About how to set the color of the background of a range... I doesn't even know how to highlight the range by selecting it.. http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
Servant Posted April 4, 2014 Author Share Posted April 4, 2014 CTRL+Alt+H to highlight the selected text but first I need to find out how can I change the default highlight color technically.. http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
water Posted April 4, 2014 Share Posted April 4, 2014 (edited) $oRange.HighlightColorIndex = wdColor enumeration wdColor enumeration Edited April 4, 2014 by water Servant 1 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 Link to comment Share on other sites More sharing options...
Servant Posted April 4, 2014 Author Share Posted April 4, 2014 I tried: $oRange.HighlightColorIndex = 255 But unfortunately, nothing happened to the set range.. http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
water Posted April 4, 2014 Share Posted April 4, 2014 Will test as soon as I'm at a Windows PC again ... 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 Link to comment Share on other sites More sharing options...
Servant Posted April 4, 2014 Author Share Posted April 4, 2014 (edited) I also tried: $oRange.HighlightColorIndex = 255 MsgBox(0, ".HighlightColorIndex", $oRange.HighlightColorIndex) And it message "9999999" instead of "255" if I'm not mistaken.. But when I try: MsgBox(0, ".HighlightColorIndex", $oRange.HighlightColorIndex) Without setting the .HighlightColorIndex it message "0". Edited April 4, 2014 by Servant http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
Servant Posted April 4, 2014 Author Share Posted April 4, 2014 I tried with the WdColorIndex Enumeration and the code "$oRange.HighlightColorIndex = 6" works! http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
water Posted April 4, 2014 Share Posted April 4, 2014 To avoid "magic numbers" I would use a constant: Global Const $wdRed = 6 ; Red color $oRange.HighlightColorIndex = $wdRed 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 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