Jump to content

CSV to Specific Excel Worksheet Question


ardrac
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...