Editing Processing an input file in Excel
Jump to:
navigation
,
search
First, you need to include Excel in your project's references. I prefer to use Microsoft.Office.Interop.Excel Version 12.0.0.0. Then you need to add this Import statement at the top of your file: Imports Microsoft.Office.Interop Don't include Excel on the Imports statement; force yourself to use Excel as a qualifier. Then add a sub that accepts a path to a file: Sub ImportDataFile(ByVal FilePath As String) Dim xlApp As Excel.Application = Nothing Try LogAction("Starting Staff Survey import...") LogAction("Selected file: " & FilePath) LogAction("Launching Excel and opening file...") xlApp = New Excel.Application xlApp.Workbooks.Open(FilePath, [ReadOnly]:=True) 'Do processing here... LogAction("Closing file and Excel...") xlApp.Workbooks(0).Close() Catch ex As Exception LogAction("Error processing with Excel: " & ex.Message) End Try xlApp.Quit() xlApp = Nothing End Sub See also [[Open File Dialog]]
|
Editing help
Personal tools
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
Edit
View history
Actions
Search
Navigation
Main page
Community portal
Current events
Recent changes
Random page
Help
Toolbox
What links here
Related changes
Special pages