Skip to content

Instantly share code, notes, and snippets.

@ErickPetru
Created September 1, 2021 00:43
Show Gist options
  • Select an option

  • Save ErickPetru/6c5cd187e71dddb2b68320b4d8152afe to your computer and use it in GitHub Desktop.

Select an option

Save ErickPetru/6c5cd187e71dddb2b68320b4d8152afe to your computer and use it in GitHub Desktop.
A partir de dois campos no suplemento, monta uma mensagem de olá e exibe no documento Word aberto.
name: Cumprimentar Usuário
description: >-
A partir de dois campos no suplemento, monta uma mensagem de olá e exibe no
documento Word aberto.
host: WORD
api_set: {}
script:
content: |
const button = document.getElementById("button") as HTMLButtonElement;
const firstName = document.getElementById("firstName") as HTMLInputElement;
const lastName = document.getElementById("lastName") as HTMLInputElement;
button.addEventListener("click", () => {
let result = ""
if (firstName.value == "" || lastName.value == "") {
result = "Eita, não digitou algum campo!";
} else {
result = `Olá, ${firstName.value} ${lastName.value}!`;
}
Word.run(async (context) => {
const body = context.document.body;
body.clear();
body.font.name = "Arial";
body.font.size = 12;
body.font.color = "black";
body.font.bold = false;
body.font.italic = false;
body.insertParagraph(result, Word.InsertLocation.start);
});
firstName.value = ''
lastName.value = ''
});
language: typescript
template:
content: |-
<input id="firstName" placeholder="Nome" />
<input id="lastName" placeholder="Sobrenome" />
<button id="button">Exibir</button>
language: html
style:
content: "body {\r\n font: 400 2rem Sans-serif;\r\n}\r\n\r\ninput {\r\n font: inherit;\r\n}\r\n\r\nbutton {\r\n font: inherit;\r\n background: black;\r\n color: white;\r\n border: none;\r\n}"
language: css
libraries: |-
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
core-js@2.4.1/client/core.min.js
@types/core-js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment