Word.StyleType enum
Represents the type of style.
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Applies the specified style to a paragraph.
await Word.run(async (context) => {
const styleName = $("#style-name-to-use").val() as string;
if (styleName == "") {
console.warn("Enter a style name to apply.");
return;
}
const style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else if (style.type != Word.StyleType.paragraph) {
console.log(`The '${styleName}' style isn't a paragraph style.`);
} else {
const body = context.document.body;
body.clear();
body.insertParagraph(
"Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document.",
"Start"
);
const paragraph = body.paragraphs.getFirst();
paragraph.style = style.nameLocal;
console.log(`'${styleName}' style applied to first paragraph.`);
}
});
Fields
character = "Character" | Represents that the style is a character style. |
list = "List" | Represents that the style is a list style. Currently supported on desktop. |
paragraph = "Paragraph" | Represents that the style is a paragraph style. |
table = "Table" | Represents that the style is a table style. |
Colaborar con nosotros en GitHub
El origen de este contenido se puede encontrar en GitHub, donde también puede crear y revisar problemas y solicitudes de incorporación de cambios. Para más información, consulte nuestra guía para colaboradores.
Comentarios
https://aka.ms/ContentUserFeedback.
Próximamente: A lo largo de 2024 iremos eliminando gradualmente GitHub Issues como mecanismo de comentarios sobre el contenido y lo sustituiremos por un nuevo sistema de comentarios. Para más información, vea:Enviar y ver comentarios de