UiPath Documentation
studiox
2023.10
false
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.
UiPath logo, featuring letters U and I in white

StudioX user guide

Última atualização 30 de abr de 2026

Tutorial: Trabalhar com a automação do Word

Neste tutorial, criaremos uma automação que gera um documento do Word para revisão do desempenho individual de cada membro de uma equipe, com base em um modelo de arquivo do Word e dados coletados de vários arquivos do Excel e de texto. O modelo de arquivo contém texto de espaço reservado e indicadores, que podem ser preenchidos com valores usando atividades do Word. Os nomes dos arquivos do Excel e de texto dos quais os dados serão copiados seguem um padrão específico que inclui o nome do funcionário.

We will start by adding a Use Excel File activity to indicate an Excel file with employee information to add to the automation. Inside it, we will add a For Each Excel Row activity to iterate through the rows with employee data. Inside For Each Excel Row, we will add a Use Word File activity to add the template document to the automation, and then a series of Replace Text, Set Bookmark Content, and Insert DataTable in Document activities will populate each Word file with the necessary information taken for each employee from an Excel file and a text file. Finally, we will add a Save Word File As activity to save the template document as a separate file for each employee.

  1. Configure o projeto e obtenha os arquivos necessários.
    1. Create a new blank project using the default settings.
    2. Baixe e extraia o arquivo com o projeto de automação neste tutorial usando o botão na parte inferior desta página. Copie a pasta Arquivos para a pasta do seu projeto.
    3. Crie uma pasta chamada Saída na pasta do seu projeto.
  2. Adicionar o Excel com os dados do funcionário ao projeto e iterar pelas linhas do arquivo.
    1. In StudioX, click Add Activity Imagem dos documentos in the Designer panel, and then find the Use Excel File activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    2. Na atividade:
      • Click Browse Imagem dos documentos next to the Excel file field, and then browse to the Files folder and select the file Employees.xlsx.

      • No campo Referenciar como, insira EmployeeData.

        Você indicou que trabalhará com o arquivo Employees.xlsx que é conhecido em sua automação como EmployeeData.

    3. Click Add Activity Imagem dos documentos inside Use Excel File, and then find the For Each Excel Row activity in the search box at the top of the screen and select it. The activity is added to the Designer panel inside the Use Excel File activity.
    4. Na atividade For Each Excel Row:
      • Na caixa de texto Para cada, substitua CurrentRow por Employee.

      • Click Plus docs image on the right side of the In range field, and then select EmployeeData > Sheet1 [Sheet].

        Você indicou que deseja iterar por todas as linhas da Sheet1 da planilha Employees. Como cada linha contém informações sobre um funcionário, a linha atual na iteração foi renomeada como Funcionário para tornar as informações da linha mais fáceis de identificar posteriormente na automação.

        Imagem dos documentos

  3. Adicionar o arquivo de modelo do Word à automação.
    1. Click Add Activity Imagem dos documentos inside For Each Excel Row, and then find the Use Word File activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    2. Na atividade Use Word File:
      • Click Browse Imagem dos documentos next to the Word file field, and then browse to the Files folder and select the file PerformanceReviewDoc_template.docx.

      • Clear the Save changes check box. This ensures that the template file is not saved with the data added for each employee.

        Você indicou que trabalhará com o arquivo modelo_DocAvaliaçãodeDesempenho.

        Imagem dos documentos

  4. Adicionar informações do arquivo do Excel com os dados do funcionário ao arquivo do Word.
    1. Click Add Activity Imagem dos documentos inside Use Word File, and then find the Replace Text activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    2. Na atividade Replace Text:
      • Click Plus Imagem dos documentos on the right side of the Search for field, and then select Text. In the Text Builder, enter <>.

      • Click Plus docs image on the right side of the Replace with field, and then select Employee > Full Name.

        You have indicated that you want to replace the placeholder text <> in the Word file with the full name that is copied for each employee from the cell in the Full Name column of the Employees Excel file.

    3. Click Add Activity Imagem dos documentos below the Replace Text activity, and then find the Set Bookmark Content activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    4. Na atividade Set Bookmark Content:
      • Click Plus Imagem dos documentos on the right side of the Bookmark name field, and then select Text. In the Text Builder, enter DirectManager.

      • Click Plus docs image on the right side of the Bookmark text field, and then select Employee > Direct Manager.

        Você indicou que, para cada funcionário, deseja adicionar o nome do gerente direto ao arquivo Word, copiando o conteúdo da célula na coluna Gerente Direto do arquivo Excel Funcionários e colando-o no local do marcador GerenteDireto no arquivo do Word.

    5. Repita as etapas 3 a 4 três vezes para adicionar atividades Set Bookmark Content adicionais, que adicionam o nome completo, localização e cargo de cada funcionário ao arquivo do Word. Configure cada atividade da seguinte maneira:
      • Nome do indicador FullName, Texto do indicador Funcionário > Nome completo

      • Nome do indicador Location, Nome do indicador Funcionário > Localização

      • Nome do indicador PositionTitle, Nome do indicador Funcionário > Título do cargo

        Imagem dos documentos

  5. Adicionar informação do arquivo Excel com dados sobre projetos ao arquivo do Word.
    1. Click Add Activity Imagem dos documentos below the last Set Bookmark Content, and then find the Use Excel File activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    2. Na atividade Use Excel File:
      • Click Plus docs image on the right side of the Excel file field, and then select Text.

        No Construtor de Texto:

        1. Insira o texto Files\

        2. Click Plus Imagem dos documentos on the right side of the Text Builder, and then select Employee > Full Name.

        3. Insira o texto _Projects.xlsx

          O texto deve ter a seguinte aparência: Files\[Employee]FullName_Projects.xlsx.

        4. Click Save in the Text Builder.

          Você indicou que, para cada funcionário, deseja adicionar o arquivo do Excel Projetos à automação. Como a seleção do Arquivo do Excel é um caminho de arquivo dinâmico e você deseja poder selecionar dados nas atividades que usam os arquivos de projetos, você indicou um dos arquivos como um modelo de arquivo.

    3. Click Add Activity Imagem dos documentos inside the newly added Use Excel File activity, and then find the Insert DataTable in Document activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    4. Na atividade Insert DataTable in Document:
      • Click Plus Imagem dos documentos on the right side of the Table to insert field, and then select Projects > Sheet1 [Sheet] > Table1 [Table].

      • No Inserir relativo a do menu suspenso, selecione Indicador.

      • Click Plus Imagem dos documentos on the right side of the Bookmark to search for field, and then select Text. In the Text Builder, enter Projects.

      • No menu suspenso Posição onde inserir, selecione Depois.

        Você indicou que, para cada funcionário, deseja copiar a Tabela1 do arquivo Excel de Projetos e colá-la no arquivo Word após o indicador denominado Projetos.

        Imagem dos documentos

  6. Adicionar informação dos arquivos de texto com feedback do gerente ao arquivo do Word e salve um arquivo separado para cada funcionário.
    1. Click Add Activity Imagem dos documentos below the newly added Use Excel File activity, and then find the Read Text File activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    2. Na atividade Read Text File:
      • Click Plus docs image on the right side of the Filename field, and then select Text.

        No Construtor de Texto:

        1. Insira o texto Files\

        2. Click Plus Imagem dos documentos on the right side of the Text Builder, and then select Employee > Full Name.

        3. Insira o texto _ManagerFeedback.txt

          O texto deve ter a seguinte aparência: Files\[Employee]FullName_ManagerFeedback.txt.

        4. Click Save in the Text Builder.

      • In the Properties panel, click Plus Imagem dos documentos on the right side of the Output to field, and then select Open in Advanced Editor. Enter the expression Saved.Values(Of String)("ManagerFeedback") and click OK.

        Você indicou que, para cada funcionário, deseja copiar o feedback do gerente do arquivo de texto que contém o nome do funcionário no nome do arquivo e deseja salvar o feedback para uso posterior na automação.

    3. Click Add Activity Imagem dos documentos below the Read Text File activity, and then find the Set Bookmark Content activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    4. Na atividade Set Bookmark Content:
      • Click Plus Imagem dos documentos on the right side of the Bookmark name field, and then select Text. In the Text Builder, enter DirectManagerFeedback.

      • Click Plus docs image on the right side of the Bookmark text field, and then select Use Saved Value > ManagerFeedback.

        Você indicou que, para cada funcionário, deseja copiar o feedback do gerente que salvou para uso posterior na atividade Read Text File e colá-lo no arquivo do Word no local do indicador DirectManagerFeedback.

        Imagem dos documentos

    5. Click Add Activity Imagem dos documentos below the Set Bookmark Content activity, and then find the Save Word File As activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.
    6. Na atividade Save Word File As.
      • Click Plus docs image on the right side of the Save as file field, and then select Text.

        No Construtor de Texto:

        1. Insira o texto Output\

        2. Click Plus Imagem dos documentos on the right side of the Text Builder, and then select Employee > Full Name.

        3. Insira o texto _PerformanceReview.docx

          O texto deve ter a seguinte aparência: Output\[Employee]FullName_PerformanceReview.docx.

        4. Click Save in the Text Builder.

      • Deixe as seleções padrão para as outras opções.

        Você indicou que deseja salvar o arquivo de modelo modificado com os dados de cada funcionário em uma nova pasta chamada Saída. O nome completo de cada funcionário será adicionado ao nome do arquivo usando o valor na coluna Nome Completo do arquivo Funcionário do Excel

    7. Click Save in the StudioX ribbon to save the automation, then click Run to execute the automation.The automation creates separate performance review Word documents for each employee in the Output folder and populates the files with information from the Excel files with employee data and projects information, and from the text files with manager feedback. Download example

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades