Good day folks,

I've been wondering how can I open an excel file in vb.net. Can somebody help me?

I always get this error below:

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

Thanks in advance

Recommended Answers

Two possible scenarios

  1. If the data is in tabular form you can open the Excel files using ADO or OleDb and read the data like a database
  2. You can use automation objects to access the data cell by cell

I have a sample project for each that I …

Jump to Post

All 4 Replies

Re: Opening excel file 80 80

For every types of file or for excel, use:
Process.Start(FilePath.Trim"\"+Filename.Trim+".xls")

Re: Opening excel file 80 80

Perhaps have a look here

Re: Opening excel file 80 80

Two possible scenarios

  1. If the data is in tabular form you can open the Excel files using ADO or OleDb and read the data like a database
  2. You can use automation objects to access the data cell by cell

I have a sample project for each that I will try to attach to this post.

commented: Great! +14
Re: Opening excel file 80 80

Thanks guys :)

I already solved my problem. And for some people with the same problem, I'll show you what I've done.

        Try
            Dim xlApp As Object
            xlApp = CreateObject("Excel.Application")
            xlApp.Visible = True
            xlApp.Workbooks.Open(strFileName)
            xlApp.UserControl = True
            xlApp = Nothing
        Catch ex As Exception
            MessageBox.Show("Excel file not found", "Validation - 125", MessageBoxButtons.OK, MessageBoxIcon.Error)
            For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
                proc.Kill()
            Next
            Exit Sub
        End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.