Solved

import data from a closed workbbok

Posted on 2014-10-06
7
63 Views
Last Modified: 2014-11-03
i am using the adapted code below to import data from a closed workbook.I am using 2013 with the xlsb extension. using the xlsb extension cases it to fail.I am importing about 20 workbooks at a time.can we modify the code to make it work ? thanks
    If Header = False Then
        If Val(Application.Version) < 12 Then
            szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source=" & SourceFile & ";" & _
                        "Extended Properties=""Excel 8.0;HDR=No"";"
        Else
            szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                        "Data Source=" & SourceFile & ";" & _
                        "Extended Properties=""Excel 12.0;HDR=No"";"
        End If
    Else
        If Val(Application.Version) < 12 Then
            szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source=" & SourceFile & ";" & _
                        "Extended Properties=""Excel 8.0;HDR=Yes"";"
        Else
            szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                        "Data Source=" & SourceFile & ";" & _
                        "Extended Properties=""Excel 12.0;HDR=Yes"";"
        End If
    End If
0
Comment
Question by:Svgmassive
  • 4
  • 2
7 Comments
 
LVL 12

Expert Comment

by:James Elliott
ID: 40363805
What string have you assigned to your 'sourcefile' variable?

Please post all of your code.

Thanks
0
 
LVL 12

Expert Comment

by:James Elliott
ID: 40363808
And also, if you are importing just xlsb files then they will only import into application.version >= 12.0

This might also be your problem.
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40363852
I am interested to see the solution for this thread. As I have similar issue with Ado which will post the question in a new thread
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Svgmassive
ID: 40363898
the sourceflle is the path and work book, what ever ou want it to be ,the last line is   cnn.Open szConnect
0
 
LVL 12

Expert Comment

by:James Elliott
ID: 40363910
Just to be clear, you say that you are having problems with a particular file extension, but yet you don't want to post details of how this is being handled in your sourcefile variable??
0
 

Author Comment

by:Svgmassive
ID: 40364183
Dim szConnect As String: Dim cnn As New ADODB.Connection:

   szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                        "Data Source=" & SourceFile & ";" & _
                        "Extended Properties=""Excel 12.0;HDR=Yes"";"


  szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\TOYS\Desktop\ALL_TEST\2014\Jul_2014\7_1_2014\Book1.xlsb;Extended Properties=Excel 8.0;

cnn.Open szConnect,,,,,,It fails right here

this should be more than enough  there is nothing more
0
 
LVL 12

Accepted Solution

by:
James Elliott earned 500 total points
ID: 40364536
Try changing extended properties 12.0 instead of 8.0
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now