ardrac Posted December 29, 2016 Share Posted December 29, 2016 Hi There, Hoping someone can help me with this. I’m trying to find a way to script the below. I have a csv file that contains some data. The data in it can change, so I need it to read all the data in it, whatever is there. I have an Excel Workbook, which contains multiple tabs/worksheets. I need to read all of the contents of the csv file, and write them to a specific worksheet in the Excel file. It didn’t sound too hard to do, but I can’t seem to get it going at all. I am trying to use the Excel UDF, rather than reading the data in the csv file line by line. I’ve looked at Excel_RangeRead Example 1 and simplified it to just this, but when I run it I get no data appearing in the message box. #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> ; Create application object and open an example workbook Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, "c:\excelstuff\source.csv") ; ***************************************************************************** ; Read data from a single cell on the active sheet of the specified workbook ; ***************************************************************************** Local $sResult = _Excel_RangeRead($oWorkbook, Default, Default) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Data successfully read." & @CRLF & "Value: " & $sResult) My theory was that once I have $sResult containing all the data I could just use RangeWrite to insert the data into the correct worksheet in the destination file. But as I am not seeing any data in the MsgBox I’m kind of stumped. I’m guessing it’s to do with it being an array, maybe. I’m not precious about how to achieve this, so if there is a better way that the Excel Range Read/Write id be keen to know, Link to comment Share on other sites More sharing options...
Jfish Posted December 29, 2016 Share Posted December 29, 2016 39 minutes ago, ardrac said: I’m guessing it’s to do with it being an array, maybe. Correct. Instead of the message box use _arrayDisplay($sResult) to see the contents you have read. ardrac 1 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
ardrac Posted December 30, 2016 Author Share Posted December 30, 2016 Thanks Jfish. Just what I needed to know. All the rest done and working now, much appreciated. 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