I want to search for values extracted from Excel, write them to Excel if they’re not found, and click if they are

Excelから抽出した値を1つずつブラウザアプリに検索にかけて、検索対象が表示されればクリック、表示されなければExcelに記載してクリック動作をスキップという動作を、抽出した値分繰り返すように設定したいです。

現在設定しているフローは以下なのですが、検索結果に対象がない場合、出力された検索結果から対象を探すのに時間がかかっているのと、検索で引っかからなかったものをExcelに記載してくれません。。。
(検索結果に対象がない場合、出力された検索結果が2件ほどであっても後続処理までに時間がかかってます。)

データテーブルの構築
追加失敗 string
変数:dttable2
…
↓
繰り返し(各UI要素)
繰り返し:現在の要素
抽出数の制限:最大UI要素数
項目数:10
↓
代入
target=CurrentRow(currentItem).ToString()
↓
トライキャッチ
トライ
クリック ※ここは問題なく動作しています。
キャッチ
NodeAmbigrousException
→繰り返し(Excelの各行)
繰り返し:CurrentRow
対象範囲:Excel.Sheet(“Sheet2”)
先頭行をヘッダーとする☑
→AddDataRow
列配列:New Object() {target}
データテーブル:dttable2
NodeNotFoundException
→繰り返し(Excelの各行)
繰り返し:CurrentRow
対象範囲:Excel.Sheet(“Sheet2”)
先頭行をヘッダーとする☑
→AddDataRow
列配列:New Object() {target}
データテーブル:dttable2

なかなか分かりにくいかと存じますが、よろしくお願いいたします。

Hello @afna

Can you perhaps share a screenshot/file for your current project?

And do you get any error message that we can use to troubleshoot, or does the activities simply not work the way you intended?

Regards
Soren

Thank you for your reply!
The screenshots are split into two images, but here they are!
Also, since this is part of a longer workflow, the data table is built outside the screenshots.


It doesn’t work as intended, and I get an error.
When I say it doesn’t work as intended, I mean that if the search returns multiple results for the item I’m looking for, it moves on to search for the next item without clicking anything or writing anything to Excel.
Ideally, if multiple results appear, it would click both, but that seems difficult to control, so I want it to write to the “Add Failed” column in Excel, but I can’t get it to work…
Also, it seems to be searching for the item in the results, but I don’t like that it takes one or two minutes…

I also get an error when there are no matching results. In that case, I get an error like the one below.
It also seems to take about four minutes…


22.10.4+Branch.support-v22.10.Sha.b4be88e3b45fb05c4bcd71885c763d4f2095f959

Source: Write Data Table to Excel

Message: The SpecialCells method of the Range class failed.

Exception Type: UiPath.Excel.ExcelException

UiPath.Excel.ExcelException: The SpecialCells method of the Range class failed. —> System.Runtime.InteropServices.COMException: The SpecialCells method of the Range class failed. at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Object aArgs, Boolean aArgsIsByRef, Int32 aArgsWrapperTypes, Type aArgsTypes, Type retType)
at Microsoft.Office.Interop.Excel.Range.SpecialCells(XlCellType Type, Object Value)
at UiPath.Excel.WorkbookApplication.<>c__DisplayClass47_1.b__1()
at UiPath.Excel.ExcelContextHelper.Execute[T](Func1 func, ExcelContext context, Object[] contextParams) --- End of inner exception stack trace --- at UiPath.Excel.ExcelContextHelper.Execute[T](Func1 func, ExcelContext context, Object contextParams)
at UiPath.Excel.WorkbookApplication.XlObject[T](Func`1 func, T& excelObject, ExcelContext context, Object contextParameters)
at UiPath.Excel.WorkbookApplication.EnsureAllCellsAreVisibleOrThrow(DataTable data, Range startRange)
at UiPath.Excel.WorkbookApplication.WriteRange(String range, DataTable data, Boolean includeHeaders)
at UiPath.Excel.Activities.Business.WriteRangeX.<>c__DisplayClass20_0.b__0()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
— End of stack trace from previous location —
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
— End of stack trace from previous location —
at UiPath.Excel.Activities.Business.WriteRangeX.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
— End of stack trace from previous location —
at UiPath.UIAutomationNext.Activities.NApplicationCard.OnFault(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
— End of stack trace from previous location —
at UiPath.UIAutomationNext.Activities.NApplicationCard.OnFault(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Thank you for your help!!