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.
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
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.
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()
Hello HareeshMR,
I’m using the below code to open the Excel but getting an Error can u pls help me to solve this issue…
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorksheetsheet As Microsoft.Office.Interop.Excel.Worksheet
xlApp = New Microsoft.Office.Interop.Excel.ApplicationClass 'create the instance of excel work book'
xlWorkbook = xlApp.Workbooks.Open("C:\Users\admin\Desktop\Project\VB.Net Process\OpenExcel\challenge.xlsx") 'Open the excel the file
xlApp.Visible=True
xlWorksheetsheet =CType(xlWorkbook.Sheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
xlWorksheetsheet.Activate()
Error Message :
Source: Invoke code
Message: Exception has been thrown by the target of an invocation.
Exception Type: System.Reflection.TargetInvocationException
Can you post the entire error please @niteenparit
Hi @vijai1,
This will open excel - faster way
Thanks. This worked for me.
I had to import Interop.Excel package in dependencies and also import the workspace in the xaml.