Floppy Posted December 3, 2014 Share Posted December 3, 2014 (edited) Hello, I'm trying to replace "%s1%" with a checkbox in a Word document. I thought I could use the font Wingdings2 to do this. (you can see here the character I would like to use: http://it.tinypic.com/r/10wqvx0/8) The problem is if I copy and paste the character from the Character Map, SciTe displays a little square instead of the character. What should I put instead? _Word_DocFindReplace($oDoc, "%s1%", "WHAT SHOULD I PUT HERE???") Edited December 3, 2014 by Floppy Link to comment Share on other sites More sharing options...
water Posted December 3, 2014 Share Posted December 3, 2014 After replacing %s1% you need to set the font for the replacing character to WingDings2. 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...
Floppy Posted December 3, 2014 Author Share Posted December 3, 2014 water, your solution is smart. But how can I change the font of all chackeboxes at once? Link to comment Share on other sites More sharing options...
MikahS Posted December 3, 2014 Share Posted December 3, 2014 Use a for loop to loop through each one and change the font? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
water Posted December 3, 2014 Share Posted December 3, 2014 Exactly. Use _Word_DocFind in a loop to find all occurrences of "%s1%" and change the font. Then replace all "%s1%" with the checkbox character. 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...
Floppy Posted December 4, 2014 Author Share Posted December 4, 2014 I tried with the following script from _Word_DocFind help file, but it underlines only the first occurance. Why? Global $oRangeFound $oRangeFound = _Word_DocFind($oDoc, "%s1%", 0) MsgBox(0,@error,$oRangeFound) If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", "Error locating the specified text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound.Underline = True While 1 $oRangeFound = _Word_DocFind($oDoc, "%s1%", -1, $oRangeFound) MsgBox(0,@error,$oRangeFound) If @error <> 0 Then ExitLoop $oRangeFound.Underline = True WEnd Link to comment Share on other sites More sharing options...
water Posted December 4, 2014 Share Posted December 4, 2014 Because you spcified -1 (Selection) as the range to be searched. Selection is the part of the document you have marked. Try 0 instead. 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...
Floppy Posted December 4, 2014 Author Share Posted December 4, 2014 I tried but it's the same: only the first occurrence gets underlined. Link to comment Share on other sites More sharing options...
water Posted December 4, 2014 Share Posted December 4, 2014 Which version of Office do you run? 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...
Floppy Posted December 5, 2014 Author Share Posted December 5, 2014 Office 2013 x64 (os Windows 8.1 x64) Link to comment Share on other sites More sharing options...
water Posted December 6, 2014 Share Posted December 6, 2014 (edited) This works fine for me and underlines all occurrences of "%s1%" in the document: #include <Word.au3> #include <MsgBoxConstants.au3> Global $oRangeFound Global $oWord = _Word_Create() Global $oDoc = _Word_DocOpen($oWord, "C:\temp\test.docx") $oRangeFound = _Word_DocFind($oDoc, "%s1%", 0) If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", "Error locating the specified text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound.Underline = True While 1 $oRangeFound = _Word_DocFind($oDoc, "%s1%", 0, $oRangeFound) If @error <> 0 Then ExitLoop $oRangeFound.Underline = True WEnd Edited December 6, 2014 by water 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...
water Posted December 6, 2014 Share Posted December 6, 2014 A played a little bit with Word and recorded a macro to insert the Wingdings2 symbols. This script works fine on Windows 7, Office 2010: #include <Word.au3> #include <MsgBoxConstants.au3> Global $oRangeFound Global $oWord = _Word_Create() Global $oDoc = _Word_DocOpen($oWord, "C:\temp\test.docx") $oRangeFound = _Word_DocFind($oDoc, "%s1%", 0) If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", "Error locating the specified text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound.InsertSymbol(-4012, "Wingdings 2", True) While 1 ConsoleWrite("**" & @CRLF) $oRangeFound = _Word_DocFind($oDoc, "%s1%", 0, $oRangeFound) If @error <> 0 Then ExitLoop $oRangeFound.InsertSymbol(-4012, "Wingdings 2", True) WEnd 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