studio
2023.10
false
Studio User Guide
Last updated Nov 4, 2024

Example of Using a While Activity

To exemplify how to use a While activity, let’s create an automation that increments an integer variable from 10 to 100, and writes all the numbers to a Microsoft Word document.

  1. Create a new sequence.
  2. Create an integer variable, Counter, with the default value of 10.
  3. Add a While activity to Designer panel.
  4. In the Condition field, type Counter < 100. This means that the body of the loop is going to be repeated until the value of the Counter variable is going to be bigger than 100.
  5. In the Body section of the While activity, add an Assign activity.
  6. In the To field, add the Counter.
  7. In the Value field, type Counter + 1. This increments the value of the Counter with one.
  8. Add an Append Text activity under the Assign one.
    Note: This activity is part of the Word activities package. If you do not have it, use the package manager functionality to install it.
  9. In the File path field, type the path of a Word document in between quotation marks.
    Note: Make sure that the Word document is not used when running the automation, otherwise a message error is displayed and the execution is stopped.
  10. In the Text field, type "The counter is now " + Counter.ToString +".".

    The final project should look as in the following screenshot.



  11. Press F5. The automation is executed.
  12. Double-click the Word document specified at step 9. Note that all the numbers between 10 and 100 are written, as expected.


Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.