Been trying to figure out how to be able to pass in an existing workbook output to my Invoke VB.Net Code. I know how to pass it via arguments and such, but in my code I use:
Microsoft.Office.Interop.Excel.Application
opposed to the UiPath library:
Uipath.Excel.WorkbookApplication
I basically want to be able to sick my invoke vb.net code into the excel application scope without having to read the file again and write some data into specific cells. But right now my code needs to handle the opening of the workbook. So there will always be a conflict-ion with the excel file being open in the excel scope as well as in my VBnet code and will throw an error. Anyone have any ideas on how to pass the workbook output to VBnet code to accomplish write jobs? My code is like this:
My code is like this For some reason it had to be separated from the post since I can’t post more than to links:
'Open the workbook you need
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
'set visibility
xlApp.Visible = True
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Open(“C:\Users\somefiletest.xlsx”)
'Reference the sheet
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet = CType(xlBook.Worksheets(“Sheet1”), Microsoft.Office.Interop.Excel.Worksheet)
'enter data and write
Dim test(,) As String = {{“04”, “h1Text”}, {“00000079”, “h2Text”}, {“03”, “054”}}
Dim xlRange As Microsoft.Office.Interop.Excel.Range = xlSheet.Range(“A12:A15”,“B12:B15”)
xlRange.Value = test
Dim worksheet As Microsoft.Office.Interop.Excel.Worksheet
Dim workbook As Microsoft.Office.Interop.Excel.Workbook
workbook = In_Workbook.CurrentWorkbook()
worksheet =DirectCast(workbook.Worksheets(“Sheet1”), Microsoft.Office.Interop.Excel.Worksheet)
Where In_Workbook is the UiPath WorkbookApplication passed as an argument in the Invoke code activity.