-
Notifications
You must be signed in to change notification settings - Fork 63
/
word.styletype.yml
85 lines (70 loc) · 2.72 KB
/
word.styletype.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
### YamlMime:TSEnum
name: Word.StyleType
uid: 'word!Word.StyleType:enum'
package: word!
fullName: Word.StyleType
summary: Represents the type of style.
remarks: >-
\[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
#### Examples
```TypeScript
// 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: Word.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: Word.Body = context.document.body;
body.clear();
body.insertParagraph(
"Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.",
"Start"
);
const paragraph: Word.Paragraph = body.paragraphs.getFirst();
paragraph.style = style.nameLocal;
console.log(`'${styleName}' style applied to first paragraph.`);
}
});
```
isPreview: false
isDeprecated: false
fields:
- name: character
uid: 'word!Word.StyleType.character:member'
package: word!
summary: |-
Represents that the style is a character style.
* \[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
value: '"Character"'
- name: list
uid: 'word!Word.StyleType.list:member'
package: word!
summary: |-
Represents that the style is a list style. Currently supported on desktop.
* \[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
value: '"List"'
- name: paragraph
uid: 'word!Word.StyleType.paragraph:member'
package: word!
summary: |-
Represents that the style is a paragraph style.
* \[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
value: '"Paragraph"'
- name: table
uid: 'word!Word.StyleType.table:member'
package: word!
summary: |-
Represents that the style is a table style.
* \[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
value: '"Table"'