# 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.

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` &lt; 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](https://docs.uipath.com/activities/docs/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](https://docs.uipath.com/activities/docs/document-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](https://docs.uipath.com/studio/standalone/2025.10/user-guide/managing-activities-packages#managing-packages) 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.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-171604-05e03ada.webp)

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.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-168561-59898460.webp)

[Download example](https://documentationexamplerepo.blob.core.windows.net/examples/Studio_v2022.10/WhileActivity.zip)
