I have used the Process.start function to open an Excel file as shown in the code

Process.Start("report.xlsx") and it works perfectly well.

My question is can this function be used to open a particular worksheet called Report1 in the report.xlsx file. If so what would the code be.

I have spent many hours trying to research this topic but without success.

Many Thanks for your help.

Not from my knowledge. The proces start determines if the target is an executable. If not tryes to search for the default program associated with the extension and launches it like if you double click on the file.

If you want to interact with Excel, you'll need to use the Excel interop object model.

You can read http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel(v=office.11).aspx for more info. And here for howtos.

Hope this helps

There have been several postings on this forum relating to accessing Excel spreadsheets from within VB. For example, I recently posted the following code which returns an array containg the names of all worksheets in a given workbook.

Private Function GetWorkSheetNames(ByVal ExcelFile As String) As String()
    Dim names As String = ""
    Dim xls As New Excel.Application
    For Each sheet As Excel.Worksheet In xls.ActiveWorkbook.Worksheets
        names = names & vbCr & sheet.Name
    Return names.Substring(1).Split(vbCr)
End Function

Hi, After opening file u can send the SendKeys.send to select the sheet in the opened excel file.

You should use the Excel methods rather than SendKeys. You can select a sheet my index (1-relative) or by name such as

sheet = xls.ActiveWorkbook.WorkSheets(3)
sheet = xls.ActiveWorkbook.WorkSheets("Sheet3")

Many thanks to all of you that answered my question. I now understand the Process.Start function better. Thankyou.