How to open excel applicatiion using VB.NET?

how to open excel using VB.NET? by using invoke code activity?

Hi,

Use open application activity and indicate an excel file when it is open and so the file name property and selector for open application activity will be set automatically.Capture

1

Hi @vijai1,

use the Below code using Invoke code sctivity

 Dim xlsApp As Excel.Application = Nothing
        Dim xlsWorkBooks As Excel.Workbooks = Nothing
        Dim xlsWB As Excel.Workbook = Nothing

        xlsApp = New Excel.Application
        xlsApp.Visible = True
        xlsWorkBooks = xlsApp.Workbooks
        xlsWB = xlsWorkbooks.Open("strExcelFilePath")

Regards,
Arivu

hi arivu,

i have got this. but we need to add a few more lines in xaml file as it is not recognizing the code.

@vijai1 can u share the code?

Hello :slight_smile:
I just want to ask why the UiPath do not recognize the Excel.Application activity.
Do I need to add some reference so I can use it?

I tried adding the Microsoft.Office.Interop.Excel on the Imports but still not working.

Hello Vijai,
This code gives error

The package Microsoft.Office.Interop.Excel may not be available in the xaml by default. So, try importing the package from the manage packages then use the below code.

Here is the sample code …

    Dim excel As Microsoft.Office.Interop.Excel.Application
    Dim wb As Microsoft.Office.Interop.Excel.Workbook
    Dim ws As Microsoft.Office.Interop.Excel.Worksheet
     excel = New Microsoft.Office.Interop.Excel.Application 'create the instance of excel work book'

        wb = excel.Workbooks.Open(" Path to the file") 'Open the excel the file
        excel.Visible = True

        ws = CType(wb.Sheets("Sheet Name"), Microsoft.Office.Interop.Excel.Worksheet) 'select a sheet and activiates'
        ws.Activate()