Getting the following error in invoke code activity doing Excel operations in it
→ added the namespace in imports.
–>added the package microsoft.office.interop.excel.
Cannot load assembly: C:\Users\XXXX.nuget\packages\microsoft.office.interop.excel/15.0.4795.1000\lib/net20/Microsoft.Office.Interop.Excel.dll : System.IO.FileNotFoundException: Could not load file or assembly ‘office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
File name: ‘office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at UiPath.Studio.Plugin.Workflow.Services.AssemblyContainer.AddAssemblyInternal(Assembly assembly, String path)
at UiPath.Studio.Plugin.Workflow.Services.AssemblyContainer.LoadAssemblies(String paths, IAppDomainCancellationToken cancellationToken)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ----> System.IO.FileNotFoundException: Could not load file or assembly ‘office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
at UiPathCodeRunner_6f8be8e01ea348f7b9292f01711c8f0c.Run(String files, String firstRange, String secondRange, String newfile)
— End of inner ExceptionDetail stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Core.Activities.Workflow.CompilerRunner.Run(Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
@HareeshMR
copying the data from one sheet and paste to other sheet.
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1,ws2 As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.Application
wb1 = excel.Workbooks.Open(files)
ws1 = CType(wb1.Sheets(“Sheet2”), Microsoft.Office.Interop.Excel.Worksheet)
ws2 = CType(wb1.Sheets(“Sheet1”), Microsoft.Office.Interop.Excel.Worksheet)
ws1.Activate()
ws2.Activate()
ws1.Range(firstRange).Copy
ws2.Range(secondRange).PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteValuesAndNumberFormats)
ws1.Delete()
wb1.SaveAs(newfile)
wb1.Close()
excel.Quit()