Week 2: Working with Decisions, Iterations and Scenarios

A post was split to a new topic: Hi! I strugled a little bit in the Copy File activity. I found myself using the “Text” feature in order to indicate the folder after indicating the “Current row”+specific cell. Is this really how it´s done?

Interesting week so far, enjoyed working on this exercise. Just few thoughts / questions to see how others have done and your views:

I created PDF outputs and didn’t copy templates (with this I noticed that my templates were overwritten
Use Switch for CV types and then one more for Images
For output folder I have to use “Text” option to provide the complete folder location - is this how it suppose to be?

Overall it was an interesting exercise.

Glad it helped :slight_smile:

Nice practical example. Just typing mistake in folder name (Picture instead of Pictures) but after update it works well. Disadvantage of Text Builder is that I can’t choose folder by “+” (to eliminate manual mistake). Am I right?

Text builder

1 Like

Bot creates 2 or 3 Word files (proving the code is ok and does what is expected) and after that starts inconsistently showing program errors like Replace text failed or Replace picture failed or error with Use Word file. Seems like not very stable piece of sw…

A post was split to a new topic: I am getting issue with word application I was not able to run it successfully. Error: The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER

Hi Andrew,

I thought the same thing at first, but as I got further into the exercise, it made sense to use it…

I used the Switch on the CV type (e.g. Resume_Cyan) in Excel. For each Excel row, the bot checks first to see what CV Type is listed. Then starts the actions in the specified Switch case (e.g. Resume_Cyan).

If Need CV is no, then it exits the Switch and goes to the next Excel row. If Need CV is Yes, then it proceeds with the rest of the actions to generate the specific resume for the matching Switch case. (Note: only the first two of the remaining actions are unique to each Switch case based on CV/Resume type - the rest of the actions are identical for all Switch cases).

  1. Copy File From Resume Templates\Resume_Cyan.docx and To Edited Resumes[CurrentRow] _Resume_Cyan.docx

  2. Use Word File is the same as Copy File To

  3. All of the remaining actions (Replace Picture, Replace Text) are nested inside the Use Word file activity.

Hope this makes sense…

Thanks for sharing,

I just used a for loop and inside that an if condition to check if need cv and then copy file and no switch after that just a use word file with variables from the excel so no need to use switch cases because what if they add a fifth cv type in the future? This is the string I used for the use word activity, see the 2 variables for name and cv type, it just grabs it from the excel without need for a switch and without user having to know what names and cv types are in the resume data. So no need to update this code if the resume data ever changes.

string.Format("{0}\Downloads\UiPath Reboot Training\Practice - Working With Multiple Templates - Working Documents\Automating Word Templates_Modified\Edited Resumes"+CurrentRow.ByField("")+"_"+CurrentRow.ByField(“CV Type”)+".docx", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))

Ahhh - yes… that’s an excellent point. The Switch would have to be revised to include the new case.

By the way, your previous post also had me think through my process, and I realized that the If condition doesn’t need to be repeated. I revised my process, still using Switch, but changed If to If CV is no, then Skip Current, else > Switch, and I deleted the individual Ifs (If CV is needed is yes) from the Switch container, so there’s less to change if a new case had to be added -

BUT to your point, it makes more sense if you can set it up so that updating the code isn’t needed at all.

Thanks for the clarification. I will definitely think think through before using a Switch whether it makes sense for the situation.

It was great.itration,switch,if all covered

This is true - the Browse option isn’t available within the Text builder. There are some ways you can still get the file path though…

  1. If there are existing files in the destination folder, select any file. Then use the Text builder to replace/edit the filename as needed…

  2. If there are no existing files to select, browse to the folder and copy the address to paste into the Text Builder (this option gives the full path - not the short/direct path from the project - so most of the path may have to be deleted except the final folder name). OR

  3. If there are no existing files to select, browse to the folder and create a file to use temporarily. Then select the new file and use Text Builder to edit/replace the filename as needed.

1 Like

Thank you for your support

Completed the exercise! I didn’t realize I had some of the wrong names in certain places so I would only run through the first line of the file. Glad I worked it out!

1 Like


When I first worked through the project, I guess I thought we were supposed to use all the new features we just learned about, but for this exercise, it wasn’t necessary and also was not the best solution. Besides, the new features are usually practiced during the narration guided projects.

People asking why the Switch was needed, made me rethink this exercise, so I recreated it without the Switch. The results are the same, but it is a cleaner project, and has much less work involved (no copying and pasting the actions to the multiple Switch cases).

And, as @andrew.ng pointed out, there will be no need to update the project if a new CV Type is ever added in the future because the process is not dependent on the limited CV Type cases of the Switch condition.

I also corrected the Copy To and Use Word file path - with either version it isn’t necessary to manually type the resume name (e.g. Resume_Cyan) since I can use CurrentRow > CV Type.

Redoing this project was quick and simple (took less than 5 minutes). All I did was set up the first part (Use Excel, For Each Excel Row, If condition, and Copy To). After that I just copied the entire Use Word container from my other project and pasted it to the new one (then updated the Use Word file path to match the Copy To file path, and the new project ran successfully on the first attempt.

I think switch is more appropriate if there are or more possible “filters” like Deposit, Withdrawal or Split deposit from the earlier exercise.

The programmatic content to date is excellent, the practical exercises are pertinent and approach the reality that is evident in administrative and financial processes with a high labor demand and operational burden on the part of the users.
For example, switches or cycles (for) could be applied to credit card reconciliations, where the statements and account statements come in different formats and the validation criteria vary, so the construction of scenarios is necessary and the analysis for example, it depends on whether different variables.

I tried again and used the Switch function and would like to try without it as some of you are suggesting…In the meantime, did any of you open the solution zip file. I did an there are lots of files in there and I didn’t know what was what. I was looking for the solution and so clicked on Main and received this error message. I also clicked on GlobalHandlerX and received the same error message. Can someone tell me what this means?


This exercise is little bit challenging but worked finally. Good learning!

I also tried to use Switch and If :frowning: