apoliemans Posted July 19, 2013 Share Posted July 19, 2013 Hi, Having problems creating a named range in Excel. What is the autoit equivalent of this VBS code: ActiveWorkbook.Names.Add Name:="tempRange", RefersTo:="=Sheet1!$A$1:$D$3" Thanks, Andre Link to comment Share on other sites More sharing options...
water Posted July 19, 2013 Share Posted July 19, 2013 (edited) Welcome to AutoIt and the forum! How do you open the workbook? Do you use the Excel UDF? Edited July 19, 2013 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...
apoliemans Posted July 19, 2013 Author Share Posted July 19, 2013 These are (some of) the statements I have at the start of my script: $Filename = "somefile.xls" Local $oExcelDoc = _ExcelBookOpen($Filename, 1, True) $oExcelDoc.workbooks.add In the active workbook I want to define a named range. Link to comment Share on other sites More sharing options...
Solution water Posted July 19, 2013 Solution Share Posted July 19, 2013 Try: #include <Excel.au3> Global $Filename = "somefile.xls" Global $oExcelDoc = _ExcelBookOpen($Filename, 1, True) Global $oWorkBook = $oExcelDoc.workbooks.add $oWorkBook.Names.Add("tempRange", "=Sheet1!$A$1:$D$3") 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...
apoliemans Posted July 19, 2013 Author Share Posted July 19, 2013 Works, thank you! Andre Link to comment Share on other sites More sharing options...
water Posted July 19, 2013 Share Posted July 19, 2013 I'm about to rewrite the Excel UDF. Do you think there should be a function to handle names of ranges (add name, list names ...)? 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...
apoliemans Posted July 20, 2013 Author Share Posted July 20, 2013 Right now I am quite happy with the example you gave above. Note that I am new to Autoit (since 1 week). My next challenge will be to create a Pivot table using this named range, I may start a new topic if I need help with that. Andre Link to comment Share on other sites More sharing options...
water Posted July 20, 2013 Share Posted July 20, 2013 If you like you could have a look at the rewrite of the Excel UDF I'm working on right now. It supports the curretn version of Excel and some functions are much faster. Unfortunately it's still in an early Alpha state. 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