UiPath Documentation
activities
latest
false
Important :
Veuillez noter que ce contenu a été localisé en partie à l’aide de la traduction automatique. La localisation du contenu nouvellement publié peut prendre 1 à 2 semaines avant d’être disponible.
UiPath logo, featuring letters U and I in white

Activités de productivité

Dernière mise à jour 6 avr. 2026

Gérer des documents Word

L'exemple ci-dessous explique comment vous pouvez personnaliser un document Word en lisant le texte du fichier, en l'affichant dans une zone de message, en ajoutant du texte et en remplaçant le texte sans même ouvrir Microsoft Word. L'exemple utilise des activités telles que Lire le texte (Read Text), Ajouter un texte (Append Text) ou Remplacer le texte dans le document (Replace Text in Document). Vous pouvez retrouver ces activités dans le package UiPath.Word.Activities.

Voici comment le processus d'automatisation peut être créé :

  1. Ouvrez Studio et démarrez un nouveau Processus.

  2. Download and extract the archive with the project in this example and copy the file document.docx to your project folder.

  3. Faites glisser un conteneur Séquence vers le concepteur de workflow.

    • Créez la variable suivante :

      Nom de variableTypes de variablesValeur par défaut
      textChaîne de caractères (string)S/O
  4. Drag a Message Box activity inside the Sequence container.

    • Ajoutez l’expression "This is the original document." dans le champ Texte.
  5. Drag a Read Text activity below the Message Box activity.

    • Add the expression "document.docx" in the File path field.
    • Ajoutez la variable text dans le champ Texte.
  6. Drag a Message Box below the Read Text activity.

    • In the Properties panel, select the Ok option from the Buttons drop-down list.
    • Ajoutez la variable text dans le champ Texte.
    • Select the check box for the TopMost option. This always brings the message box to the foreground.
  7. Drag a Message Box below the previous Message Box activity.

    • In the Properties panel, select the Ok option from the Buttons drop-down list.
    • Ajoutez l’expression "A new paragraph is added" dans le champ Texte.
    • Select the check box for the TopMost option. This always brings the message box to the foreground.
  8. Drag an Append Text activity below the Message Box activity.

    • Add the expression "document.docx" in the File path field.
    • Add the following expression in the Text field: "Nulla eu arcu a urna ultrices scelerisque nec in lectus. Suspendisse iaculis cursus turpis. Sed sed nibh in augue molestie egestas sit amet ac justo. Suspendisse facilisis, mi scelerisque mattis elementum, leo nisi euismod turpis, sed consequat nibh nulla non ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mauris risus, aliquam vel tristique blandit, consectetur ac nunc. Phasellus convallis dolor ligula, non auctor nulla lobortis sit amet. Nulla eu lectus fermentum, porttitor metus in, consectetur ex. Vivamus gravida justo et auctor fermentum. Cras nisl urna, blandit et elementum sit amet, sodales ut tellus. In sit amet semper lectus. Donec ac ipsum vel libero mattis porta vitae id velit. Nullam facilisis porttitor elementum. Ut congue tristique nisi, ornare porta enim mattis eu. Donec in lacus risus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.".
    • Select the check box for the New line option.
  9. Drag a Read Text activity below the Append Text activity.

    • Add the expression "document.docx" in the File path field.
    • Ajoutez la variable text dans le champ Texte.
  10. Drag a Message Box below the Read Text activity.

    • In the Properties panel, select the Ok option from the Buttons drop-down list.
    • Add the value text in the Text field.
    • Select the check box for the TopMost option. This always brings the message box to the foreground.
  11. Drag a Message Box below the previous Message Box activity.

    • In the Properties panel, select the Ok option from the Buttons drop-down list.
    • Add the value "Replace all the occurrences of the word "lorem" with "REPLACED"" in the Text field.
    • Select the check box for the TopMost option. This always brings the message box to the foreground.
  12. Drag a Replace Text activity below the Message Box activity.

    • Add the expression "document.docx" in the File path field.
    • Add the value "REPLACED" in the Replace field.
    • Add the value "lorem" in the Search field.
  13. Drag a Read Text activity below the Replace Text activity.

    • Add the expression "document.docx" in the File path field.
    • Ajoutez la variable text dans le champ Texte.
  14. Drag a Message Box activity below the Read Text activity.

    • In the Properties panel, select the Ok option from the Buttons drop-down list.
    • Add the value text in the Text field.
    • Select the check box for the TopMost option. This always brings the message box to the foreground.
  15. Drag a Message Box activity below the previous Message Box activity.

    • In the Properties panel, select the Ok option from the Buttons drop-down list.

    • Add the value "This activity doesn't need to open Word to interact with it. Thank you and goodbye!" in the Text field.

    • Select the check box for the TopMost option. This always brings the message box to the foreground.

    • Voici à quoi devrait ressembler votre workflow :

      docs image

  16. Exécutez le processus. Plusieurs boîtes de message affichent le texte d'origine du document, le texte avec le paragraphe ajouté et le texte avec le mot remplacé.

Cette page vous a-t-elle été utile ?

Connecter

Besoin d'aide ? Assistance

Vous souhaitez apprendre ? UiPath Academy

Vous avez des questions ? UiPath Forum

Rester à jour