pecsenye Posted February 15, 2022 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!
Danp2 Posted February 15, 2022 Posted February 15, 2022 Have you tried using _Excel_BookAttach instead of _Excel_BookOpen? Latest Webdriver UDF Release Webdriver Wiki FAQs
pecsenye Posted February 15, 2022 Author Posted February 15, 2022 (edited) Then error message: Variable must be of type "Object". Edited February 15, 2022 by pecsenye
water Posted February 15, 2022 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: Reveal hidden contents 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
pecsenye Posted February 15, 2022 Author 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.
water Posted February 15, 2022 Posted February 15, 2022 Check the help file. Every _Excel_* function comes with examples that do full error checking. My UDFs and Tutorials: Reveal hidden contents 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
Danp2 Posted February 15, 2022 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
pecsenye Posted February 15, 2022 Author Posted February 15, 2022 yes i just exchanged in the second row... Yes i see it doesn't work
pecsenye Posted February 15, 2022 Author Posted February 15, 2022 On 2/15/2022 at 6:52 PM, water said: You should always check @error and @extended after calling an _Excel_* function to make sure everything worked as expected. Expand Okay. The examples in the help file run without error.
water Posted February 15, 2022 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: Reveal hidden contents 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
pecsenye Posted February 15, 2022 Author Posted February 15, 2022 (edited) On 2/15/2022 at 8:32 PM, 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? Expand I'm trying... Update: It worked! Sure, the code "isn't nice", but it works! Edited February 16, 2022 by pecsenye
water Posted February 16, 2022 Posted February 16, 2022 My UDFs and Tutorials: Reveal hidden contents 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
juxwillx Posted February 16, 2022 Posted February 16, 2022 Did you check @extended and @error after calling the function?
pecsenye Posted February 16, 2022 Author Posted February 16, 2022 On 2/16/2022 at 9:05 AM, water said: Expand 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.
Solution water Posted February 16, 2022 Solution 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: Reveal hidden contents 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
pecsenye Posted February 16, 2022 Author Posted February 16, 2022 On 2/16/2022 at 11:41 AM, 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. Expand 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!
water Posted February 16, 2022 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: Reveal hidden contents 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
water Posted February 16, 2022 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: Reveal hidden contents 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
pecsenye Posted February 16, 2022 Author Posted February 16, 2022 (edited) On 2/16/2022 at 12:50 PM, water said: If you need to process the URL (extract data etc.) then I suggest to use IE: $oIE = _IECreate($sCellValue) Expand 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
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