my first .NET AAAAARRRRRGGGGGHHHHH!!!
The code below extends previous posts and IMHO should work. I attached an updated test.accdb and test.xlsx for anyone who cares. test,xlsx was created with Office 2013, but "SELECT * INTO [Excel 12.0;" should be accurate. The SELECT INTO syntax was 'borrowed' from a Bing search as a suggested .NET method to get data from Access to Excel.
;Winbatch 2013 - CLR - OLEDB {baby steps} - Insert Access data to Excel
;
;
;Stan Littlefield July 12, 2013
;////////////////////////////////////////////////////////////////////////////////////////////////////////
cACCDB = Dirscript():"test.accdb"
If ! FileExist(cACCDB) Then Terminate(@TRUE,"Cannot Continue","Missing Database File: ":cACCDB)
cXLS = Dirscript():"test.xlsx"
If ! FileExist(cXLS) Then Terminate(@TRUE,"Cannot Continue","Missing Excel File: ":cXLS)
cConn = 'Provider=Microsoft.ACE.OLEDB.12.0;data source=':cACCDB ; cannot use ';Connect Timeout=30;'
ObjectClrOption("use","System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
oProvider = ObjectClrNew("System.Data.OleDb.OleDbConnection",cConn)
oProvider.Open()
;putting all the eggs in one basket
oCommand = ObjectClrNew("System.Data.OleDb.OleDbCommand","SELECT * INTO [Excel 12.0;DATABASE=":cXLS:";HDR=NO;IMEX=1;].[Sheet1] from [DOW]", oProvider)
;errors here
oCommand.ExecuteNonQuery()
oCommand=0
oProvider.Dispose()
oProvider=0
Exit