Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Excel data to access using VB Script
#1
Not Solved
I need to Export an excel sheet to an access table. I get one new excel sheet every month. I could able to do this with the below script.

Option Explicit

Code:
Dim objADOXDatabase,objExcelConn,objAccessConn,objAccessRS,objExcelRS,strSQL
Set objADOXDatabase = CreateObject("ADOX.Catalog")

'Create the database file
objADOXDatabase.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=w:\customer.mdb"

Set objADOXDatabase=Nothing

Set objExcelConn = CreateObject("ADODB.Connection")
Set objAccessConn = CreateObject("ADODB.Connection")

objAccessConn.open  "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=W:\customer.mdb"
'objExcelConn.Open objAccessConn
  
objExcelConn.Provider = "Microsoft.Jet.OLEDB.4.0"
objExcelConn.Properties("Extended Properties").Value = "Excel 8.0"
objExcelConn.Open "W:\test.xls"
  
set objAccessRS = Createobject("ADODB.Recordset")
Set objExcelRS = CreateObject("ADODB.Recordset")

strSQL = "SELECT * INTO [Scenario] FROM [Excel 8.0;DATABASE=W:\test.xls;HDR=No;IMEX=1].[sheet1$];"
objAccessConn.Execute strSQL


But when i am executing this script i am getting an error in the last line "Record is too large". My excel sheet is containing around 255 columns and 2100 rows.

Can anyone tell me how to resolve this error and successfully import excel sheet to access table?

Any help is appreciated!

Thanks
Sheela
Reply
#2
Not Solved
Not sure,I think, this could be a data issue.
When you import tables from Excel the field length defaults to 255 characters (or 256 bytes). May be with your fields it is going over the limit.
Your need to normalize your data. analyze the data and create multiple tables. Then link to portions of the spreadsheet and append the data correctly to the tables.

Reply
#3
Not Solved
I can not split this into multiple table. I want this in one single table. Is there any way to import excel data as Memo field in access using VB script.

Thanks
Sheela
Reply
#4
Not Solved
May be, I am not an expert in access but as i can understand if there are too many fields and it goes over the limit then it wont be possible.
you will have to use multiple tables.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Access MS Excel Controls using QTP gayuamlu 0 2,197 06-13-2015, 02:06 AM
Last Post: gayuamlu
  Search and import data from excel under some rules. nwpulele 2 2,969 02-19-2015, 04:10 AM
Last Post: supputuri
  Excel and Driver Script shipu 1 3,861 02-27-2014, 09:09 AM
Last Post: supputuri
Question QTP Script for enter data to DB geethu105 2 3,337 02-24-2014, 06:54 PM
Last Post: guin.anirban
  How to populate data in weblist using excel vijifun 1 3,349 12-05-2013, 12:06 PM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)