LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding data from multiple worksheets of the same type Leonp Excel Discussion (Misc queries) 0 March 4th 10 09:43 AM
VBA Import Convert Data Type from Type 1 to Type 2 u473 Excel Programming 3 October 21st 08 08:22 PM
Keep data visable in excel from vbscript input AEV Excel Programming 0 February 17th 06 02:31 PM
Inserting large amounts of data with VBScript... Volker Hetzer Excel Programming 1 August 23rd 05 04:13 PM
Creating properly formatted text file from vbscript using excel data msnews.microsoft.com[_7_] Excel Programming 2 December 18th 03 09:33 PM


All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"