Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Data type issues adding data from vbscript
Hi
I have an excel 12 spreadsheet. With a simple vbscript, I can add some data to this excel spreadsheet. This works fine. The problem I have, are the data types. I need to add the current date to this excel spreadsheet. But regardless of the column format in the excel spreadsheet, the added values have "Standard" as data type. The pre defined data type in the excel spreadsheet column (type = date) seems to be ignored. Also changing the data type after the import does not solve the problem. Only switching to the edit mode of an excel spreadsheet field solves the problem. After adding a date value, the value is left aligned in the excel spreadsheet field. After switching to the edit mode, the value is right aligned in the excel spreadsheet field and the data type changes to date. vbscript: dtDate = Date strFileName = "c:\temp\logonlog.xlsx" strProvider = "Provider=Microsoft.ACE.OLEDB.12.0" strDataSource = "Data Source="+ strfilename strExtend = "Extended Properties='Excel 12.0;HDR=YES'" Set objExConnection = CreateObject("ADODB.Connection") objExConnection.Open strProvider + ";" + strDataSource + ";" + strExtend ' Without converting to string, the code generates a type mismatch error objExConnection.Execute "Insert into log (logdate) values ('" + cstr(dtDate) + "')" objExConnection.close() Special thanks for your support. Chris |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding data from multiple worksheets of the same type | Excel Discussion (Misc queries) | |||
VBA Import Convert Data Type from Type 1 to Type 2 | Excel Programming | |||
Keep data visable in excel from vbscript input | Excel Programming | |||
Inserting large amounts of data with VBScript... | Excel Programming | |||
Creating properly formatted text file from vbscript using excel data | Excel Programming |