pecsenye Posted February 15, 2022 Share Posted February 15, 2022 Here it's the code. It's good and works for me but... My problem: It's opening the "Test.xlsm" and working in it and still working while I using this "Test.xlsm" excel. Cause I always using the "Test.xlsm" therefore I would like to the currently opened Test.xlsm working in DataSheet and don't open another "Test.xlsm" Excel. Code: #include <IE.au3> #include <Array.au3> #include <Excel.au3> Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsm") $oWorkbook.Sheets("DataSheet").Activate Local $iRow2Write2 = 1 Local $oIE = _IECreate("URL", 0, 0) Local $oTableCollection = _IETableGetCollection($oIE) For $oAll In $oTableCollection $aTableData = _IETableWriteToArray($oAll, True) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aTableData, "A" & $iRow2Write2) $iRow2Write2 = $oWorkBook.Activesheet.UsedRange.Rows.Count + 1 Next _IEQuit($oIE) Thanks for helping! Link to comment Share on other sites More sharing options...
Danp2 Posted February 15, 2022 Share Posted February 15, 2022 Have you tried using _Excel_BookAttach instead of _Excel_BookOpen? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pecsenye Posted February 15, 2022 Author Share Posted February 15, 2022 (edited) Then error message: Variable must be of type "Object". Edited February 15, 2022 by pecsenye Link to comment Share on other sites More sharing options...
water Posted February 15, 2022 Share Posted February 15, 2022 You should always check @error and @extended after calling an _Excel_* function to make sure everything worked as expected. 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...
pecsenye Posted February 15, 2022 Author Share Posted February 15, 2022 ok and how do i do it? The original code works perfectly, but if I replace Excel_BookOpen / Excel_BookAttach then I get an error message. Link to comment Share on other sites More sharing options...
water Posted February 15, 2022 Share Posted February 15, 2022 Check the help file. Every _Excel_* function comes with examples that do full error checking. 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...
Danp2 Posted February 15, 2022 Share Posted February 15, 2022 You haven't shown us the revised line of code, so we can only guess at what is wrong. If you simply changed the function name without adjusting the parameters, then that won't work. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pecsenye Posted February 15, 2022 Author Share Posted February 15, 2022 yes i just exchanged in the second row... Yes i see it doesn't work Link to comment Share on other sites More sharing options...
pecsenye Posted February 15, 2022 Author Share Posted February 15, 2022 41 minutes ago, water said: You should always check @error and @extended after calling an _Excel_* function to make sure everything worked as expected. Okay. The examples in the help file run without error. Link to comment Share on other sites More sharing options...
water Posted February 15, 2022 Share Posted February 15, 2022 That's fine because I have written those example scripts, added code to do the error checking and tested them Now guess what you have to do to your code? 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...
pecsenye Posted February 15, 2022 Author Share Posted February 15, 2022 (edited) 4 hours ago, water said: That's fine because I have written those example scripts, added code to do the error checking and tested them Now guess what you have to do to your code? I'm trying... Update: It worked! Sure, the code "isn't nice", but it works! Edited February 16, 2022 by pecsenye Link to comment Share on other sites More sharing options...
water Posted February 16, 2022 Share Posted February 16, 2022 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...
juxwillx Posted February 16, 2022 Share Posted February 16, 2022 Did you check @extended and @error after calling the function? Link to comment Share on other sites More sharing options...
pecsenye Posted February 16, 2022 Author Share Posted February 16, 2022 2 hours ago, water said: Thanks! I have an other question: is there any solution that the code in the url came from an Excel cell? For example if A1 cell valie = www.autoit.com then open this link, if A1 cell value = www.google.com then open it. Link to comment Share on other sites More sharing options...
Solution water Posted February 16, 2022 Solution Share Posted February 16, 2022 Use _Excel_RangeRead to read the cell into a variable ($sCellValue) , then use "ShellExecute($sCellValue)" to call the default browser and open the URL. 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...
pecsenye Posted February 16, 2022 Author Share Posted February 16, 2022 15 minutes ago, water said: Use _Excel_RangeRead to read the cell into a variable ($sCellValue) , then use "ShellExecute($sCellValue)" to call the default browser and open the URL. Ok, so this is original code: Local $sFileName1 = @ScriptDir & "\Test.xlsm" Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsm") $oWorkbook = _Excel_BookAttach($sFileName1) $oWorkbook.Sheets("DataSheet").Activate Local $iRow2Write2 = 1 Local $oIE = _IECreate("URL", 0, 0) Local $oTableCollection = _IETableGetCollection($oIE) For $oAll In $oTableCollection $aTableData = _IETableWriteToArray($oAll, True) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aTableData, "A" & $iRow2Write2) $iRow2Write2 = $oWorkBook.Activesheet.UsedRange.Rows.Count + 1 Next _IEQuit($oIE) It's working... I trying what you wrote to me, but I need help! Local $sFileName1 = @ScriptDir & "\Test.xlsm" $sCellValue = $oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2) Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsm") $oWorkbook = _Excel_BookAttach($sFileName1) $oWorkbook.Sheets("DataSheet").Activate Local $iRow2Write2 = 1 ShellExecute($sCellValue) ;~ Local $oIE = _IECreate("URL", 0, 0) Local $oTableCollection = _IETableGetCollection($oIE) For $oAll In $oTableCollection $aTableData = _IETableWriteToArray($oAll, True) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aTableData, "A" & $iRow2Write2) $iRow2Write2 = $oWorkBook.Activesheet.UsedRange.Rows.Count + 1 Next This might be the last step... Thank you! Link to comment Share on other sites More sharing options...
water Posted February 16, 2022 Share Posted February 16, 2022 Again, this is wrong: Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsm") ; Returns the workbook object $oWorkbook = _Excel_BookAttach($sFileName1) ; Returns the workbook object BookOpen opens an existing workbook, Attach connects to a workbook manually opened by the user Means: Use Open OR Attach. 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 February 16, 2022 Share Posted February 16, 2022 If you need to process the URL (extract data etc.) then I suggest to use IE: $oIE = _IECreate($sCellValue) 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...
pecsenye Posted February 16, 2022 Author Share Posted February 16, 2022 Link to comment Share on other sites More sharing options...
pecsenye Posted February 16, 2022 Author Share Posted February 16, 2022 (edited) 3 hours ago, water said: If you need to process the URL (extract data etc.) then I suggest to use IE: $oIE = _IECreate($sCellValue) Thanks! It works now! But now I see the open website. i tried @ SW_HIDE but it doesn't work. Code: #include <IE.au3> #include <Array.au3> #include <Excel.au3> Local $sFileName1 = @ScriptDir & "\Test.xlsm" Local $oExcel = _Excel_Open() $oWorkbook = _Excel_BookAttach($sFileName1) $oWorkbook.Sheets("DataTable").Activate Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2) Local $iRow2Write2 = 1 Local $oIE = _IECreate($aResult) Local $oTableCollection = _IETableGetCollection($oIE) For $oAll In $oTableCollection $aTableData = _IETableWriteToArray($oAll, True) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aTableData, "A" & $iRow2Write2) $iRow2Write2 = $oWorkBook.Activesheet.UsedRange.Rows.Count + 1 Next _IEQuit($oIE) Edited February 16, 2022 by pecsenye 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