Tushar Posted April 20, 2022 Share Posted April 20, 2022 @water Hlo folks, I m trying to open a workbook in excel and then open a particular sheet. I don't find any way to resolve this problem. I also trying _ExcelSheetActivate() function but this will not work. Here is my code Local $oExcel_1= _Excel_Open() Local $sWorkbook="C:\Users\Tushar Verma\Desktop\AUTO IT\Test.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel_1,$sWorkbook) _ExcelSheetActivate($oExcel_1, "Test") ; I want to open this sheet (Test) but this will not open WinActivate($oWorkbook) Sleep(3000) $read1=_Excel_RangeRead($oWorkbook,Default,"A2") Thanks in advance !! Link to comment Share on other sites More sharing options...
Subz Posted April 20, 2022 Share Posted April 20, 2022 Look at _Excel_BookAttach to attach to an open workbook Link to comment Share on other sites More sharing options...
Tushar Posted April 20, 2022 Author Share Posted April 20, 2022 @Subz I want to open Particular sheet in current workbook not a different Workbook ! Link to comment Share on other sites More sharing options...
Subz Posted April 20, 2022 Share Posted April 20, 2022 Sorry read your post wrong, you can just use _Excel_RangeRead and the second parameter would be the name of your work sheet. Link to comment Share on other sites More sharing options...
water Posted April 20, 2022 Share Posted April 20, 2022 _ExcelSheetActivate is a function of a very, very old version of AutoIt. The Excel UDF has been rewritten since and all functions renamed to _Excel_*. Some of them have been dropped. Please see the AutoIt change history. With activating a specific sheet you automate the Excel GUI. With the Excel UDF you use the COM interface. I suggest to not mix this two. Use the correct UDF function for your goal and pass the sheet number or name to process as parameter. What exactly do you want to do with the selected sheet? 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...
Subz Posted April 20, 2022 Share Posted April 20, 2022 If you want to activate a worksheet you can also use the $oWorkbook.Worksheets("Sheet1").Activate to make it the active sheet. Example below: #include <Array.au3> #include <Excel.au3> Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Workbook.xlsx") ;~ Activate/Navigate to worksheet "Sheet1" ;~ nb: Not required to use _Excel_RangeRead $oWorkbook.WorkSheets("Sheet1").Activate ;~ Read range A1:B4 on Sheet1 Local $aWorkbook = _Excel_RangeRead($oWorkbook, "Sheet1", "A1:B4") _ArrayDisplay($aWorkbook) Link to comment Share on other sites More sharing options...
Tushar Posted April 20, 2022 Author Share Posted April 20, 2022 Thanks you soo much @Subz 😇 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