Read EXCEL File

Reading EXCEL Files
Occasionally I receive a file that was created in some software packages where I can’t see either the first or last column using the code below.

If I open the file in excel and save the file then the missing column is displayed.

I’ve tried referencing
Reference Microsoft ActiveX Data Obect 2.6 Libary
Reference Microsoft ActiveX Data Obect 2.7 Library
Reference Microsoft ActiveX Data Obect 2.8 Library
With no difference

The attachmet is the Sub that reades the Excel File and writes the contents to a Tab Delimited File.

I suspect the problem may be in open syntex ( see below )

Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=" & sExcelFileName & ";" & _
           "Extended Properties=""Excel 8.0;HDR=YES;"""

Any help will be appreciated.
Phil ChapmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How about just opening in Excel and saving the file via VB?

Public Sub saveSheets()
  Dim xlApp As Object
  Dim xlBook As Object
  Dim xlSheet As Object
  Dim strOutputFileName

  Set xlApp = CreateObject("Excel.Application")
  Set xlBook = xlApp.Workbooks.Open("E:\Temp\MyFile.xls")
  For Each xlSheet In xlBook.Worksheets
    strOutputFileName = "C:\TEMP\MyFile2.xls"
    xlSheet.SaveAs strOutputFileName
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Phil ChapmanAuthor Commented:
Great Answer

I'm opening another quest how to save the file as a Tab Delimited File instead of a Excel file

Save Excel File as a Tab Delimited File
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Temp\MyFile.xls")
strOutputFileName = "C:\TEMP\MyFile.txt"
xlApp.ActiveWorkbook.SaveAs strOutputFileName,-4158,false 'this saves as tabdelimited file
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Phil ChapmanAuthor Commented:
It working ok but it's asking if I won't to save the chagnes how can I suspress this?
Phil ChapmanAuthor Commented:
I found the answer

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(InputFileName)
xlApp.ActiveWorkbook.SaveAs OutPutFileName, -4158, False 'this saves as tabdelimited file
xlApp.Application.DisplayAlerts = False
Glad you were able to find the answer for the prompt.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.