exe.bat
exe.bat

Reputation: 360

Microsoft Access Runtime 2013 - import from Excel

I developed an Access database solution that is using Excel automation to open xls and xlsx files so I can import specific cells that I need.

Now I had to deploy my software to an user that does not have Office nor Excel installed and is using Runtime do run my program and I can not use automation any more.

Is there any way I can open an Excel file without Excel and import lets say cell B7 and cell E4 ? I dont need to import it in the table directly but to operate with results from xls in the memory (as I did with Excel object) and save it later.

Thanks in advance.

Upvotes: 0

Views: 1292

Answers (2)

Chris Rolliston
Chris Rolliston

Reputation: 4808

With some (quite severe) limitations, it is possible to use Jet (i.e., the Access database engine, an ageing version of which is a standard Windows component) to read XLS files at least. For the limitations see here:

http://support.microsoft.com/kb/257819/en-gb

As for an example...

Function ReadCell(XLSFileName As String, SheetName As String, CellName As String)
  Dim DB As DAO.Database, RS As DAO.Recordset
  Set DB = DBEngine.OpenDatabase(XLSFileName, False, True, "Excel 8.0;HDR=No;")
  Set RS = DB.OpenRecordset("SELECT * FROM [" + SheetName + "$" + CellName + ":" + CellName "]")
  ReadCell = RS(0)
  RS.Close
  DB.Close
End Function

Sub Foo
   MsgBox ReadCell("C:\Users\ExeBat\Documents\Test.xls", "Summary Details", "C5")
End Sub

Upvotes: 1

Shawn
Shawn

Reputation: 889

My guess is not without a 3rd party library of some sort. Potentially you could read the file as text if it was stored as office open XML, my guess is that MS encrypts/obfuscates your standard xls/xlsx file by default so you cannot though. If Excel isn't available on your user machines in all cases you might need to look into having the source data in another format (text, csv, etc), I know that is probably not an ideal answer though.

Upvotes: 0

Related Questions