VBA code for read an Excel file
I want to make an excel file read using a VBA code in a simulation software. Please let me know how 开发者_运维问答can I do this?
A very basic outline would be:
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open "C:\foo.xls"
' do stuff here
xlApp.Quit
Set xlApp = Nothing
Depending on what you actually want to achieve you may want to consider:
- saving an Excel worksheet as a CSV (comma separated value) file and reading directly from the CSV file
- using ADO to treat an Excel worksheet as a database table so that you can use SQL to read from it
精彩评论