/
word.body.yml
2066 lines (1659 loc) · 78.9 KB
/
word.body.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### YamlMime:TSType
name: Word.Body
uid: 'word!Word.Body:class'
package: word!
fullName: Word.Body
summary: Represents the body of a document or a section.
remarks: '\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: class
properties:
- name: contentControls
uid: 'word!Word.Body#contentControls:member'
package: word!
fullName: contentControls
summary: Gets the collection of rich text content control objects in the body.
remarks: '\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly contentControls: Word.ContentControlCollection;'
return:
type: '<xref uid="word!Word.ContentControlCollection:class" />'
- name: context
uid: 'word!Word.Body#context:member'
package: word!
fullName: context
summary: >-
The request context associated with the object. This connects the add-in's process to the Office host
application's process.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'context: RequestContext;'
return:
type: '<xref uid="word!Word.RequestContext:class" />'
- name: endnotes
uid: 'word!Word.Body#endnotes:member'
package: word!
fullName: endnotes
summary: Gets the collection of endnotes in the body.
remarks: '\[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly endnotes: Word.NoteItemCollection;'
return:
type: '<xref uid="word!Word.NoteItemCollection:class" />'
- name: fields
uid: 'word!Word.Body#fields:member'
package: word!
fullName: fields
summary: Gets the collection of field objects in the body.
remarks: >-
\[ [API set: WordApi 1.4](/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-fields.yaml
// Gets all fields in the document body.
await Word.run(async (context) => {
const fields = context.document.body.fields.load("items");
await context.sync();
if (fields.items.length === 0) {
console.log("No fields in this document.");
} else {
fields.load(["code", "result"]);
await context.sync();
for (let i = 0; i < fields.items.length; i++) {
console.log(`Field ${i + 1}'s code: ${fields.items[i].code}`, `Field ${i + 1}'s result: ${JSON.stringify(fields.items[i].result)}`);
}
}
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly fields: Word.FieldCollection;'
return:
type: '<xref uid="word!Word.FieldCollection:class" />'
- name: font
uid: 'word!Word.Body#font:member'
package: word!
fullName: font
summary: 'Gets the text format of the body. Use this to get and set font name, size, color and other properties.'
remarks: >-
\[ [API set: WordApi 1.1](/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-body.yaml
// Gets the style and the font size, font name, and font color properties on the body object.
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the document body.
const body = context.document.body;
// Queue a command to load font and style information for the document body.
body.load("font/size, font/name, font/color, style");
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
await context.sync();
// Show font-related property values on the body object.
const results =
"Font size: " +
body.font.size +
"; Font name: " +
body.font.name +
"; Font color: " +
body.font.color +
"; Body style: " +
body.style;
console.log(results);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly font: Word.Font;'
return:
type: '<xref uid="word!Word.Font:class" />'
- name: footnotes
uid: 'word!Word.Body#footnotes:member'
package: word!
fullName: footnotes
summary: Gets the collection of footnotes in the body.
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-footnotes.yaml
// Gets the footnotes in the document body.
await Word.run(async (context) => {
const footnotes = context.document.body.footnotes;
footnotes.load("length");
await context.sync();
console.log("Number of footnotes in the document body: " + footnotes.items.length);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly footnotes: Word.NoteItemCollection;'
return:
type: '<xref uid="word!Word.NoteItemCollection:class" />'
- name: inlinePictures
uid: 'word!Word.Body#inlinePictures:member'
package: word!
fullName: inlinePictures
summary: Gets the collection of InlinePicture objects in the body. The collection doesn't include floating images.
remarks: >-
\[ [API set: WordApi 1.1](/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/15-images/insert-and-get-pictures.yaml
// Gets the first image in the document.
await Word.run(async (context) => {
const firstPicture = context.document.body.inlinePictures.getFirst();
firstPicture.load("width, height");
await context.sync();
console.log(`Image dimensions: ${firstPicture.width} x ${firstPicture.height}`);
// Get the image encoded as Base64.
const base64 = firstPicture.getBase64ImageSrc();
await context.sync();
console.log(base64.value);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly inlinePictures: Word.InlinePictureCollection;'
return:
type: '<xref uid="word!Word.InlinePictureCollection:class" />'
- name: lists
uid: 'word!Word.Body#lists:member'
package: word!
fullName: lists
summary: Gets the collection of list objects in the body.
remarks: >-
\[ [API set: WordApi 1.3](/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/20-lists/organize-list.yaml
// Gets information about the first list in the document.
await Word.run(async (context) => {
const lists = context.document.body.lists;
lists.load("items");
await context.sync();
if (lists.items.length === 0) {
console.warn("There are no lists in this document.");
return;
}
// Get the first list.
const list = lists.getFirst();
list.load("levelTypes,levelExistences");
await context.sync();
const levelTypes = list.levelTypes;
console.log("Level types of the first list:");
for (let i = 0; i < levelTypes.length; i++) {
console.log(`- Level ${i + 1} (index ${i}): ${levelTypes[i]}`);
}
const levelExistences = list.levelExistences;
console.log("Level existences of the first list:");
for (let i = 0; i < levelExistences.length; i++) {
console.log(`- Level ${i + 1} (index ${i}): ${levelExistences[i]}`);
}
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly lists: Word.ListCollection;'
return:
type: '<xref uid="word!Word.ListCollection:class" />'
- name: paragraphs
uid: 'word!Word.Body#paragraphs:member'
package: word!
fullName: paragraphs
summary: Gets the collection of paragraph objects in the body.
remarks: >-
\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
Important: Paragraphs in tables aren't returned for requirement sets 1.1 and 1.2. From requirement set 1.3,
paragraphs in tables are also returned.
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-word-count.yaml
// Counts how many times each term appears in the document.
await Word.run(async (context) => {
const paragraphs = context.document.body.paragraphs;
paragraphs.load("text");
await context.sync();
// Split up the document text using existing spaces as the delimiter.
let text = [];
paragraphs.items.forEach((item) => {
let paragraph = item.text.trim();
if (paragraph) {
paragraph.split(" ").forEach((term) => {
let currentTerm = term.trim();
if (currentTerm) {
text.push(currentTerm);
}
});
}
});
// Determine the list of unique terms.
let makeTextDistinct = new Set(text);
let distinctText = Array.from(makeTextDistinct);
let allSearchResults = [];
for (let i = 0; i < distinctText.length; i++) {
let results = context.document.body.search(distinctText[i], { matchCase: true, matchWholeWord: true });
results.load("text");
// Map each search term with its results.
let correlatedResults = {
searchTerm: distinctText[i],
hits: results
};
allSearchResults.push(correlatedResults);
}
await context.sync();
// Display the count for each search term.
allSearchResults.forEach((result) => {
let length = result.hits.items.length;
console.log("Search term: " + result.searchTerm + " => Count: " + length);
});
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly paragraphs: Word.ParagraphCollection;'
return:
type: '<xref uid="word!Word.ParagraphCollection:class" />'
- name: parentBody
uid: 'word!Word.Body#parentBody:member'
package: word!
fullName: parentBody
summary: >-
Gets the parent body of the body. For example, a table cell body's parent body could be a header. Throws an
`ItemNotFound` error if there isn't a parent body.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentBody: Word.Body;'
return:
type: '<xref uid="word!Word.Body:class" />'
- name: parentBodyOrNullObject
uid: 'word!Word.Body#parentBodyOrNullObject:member'
package: word!
fullName: parentBodyOrNullObject
summary: >-
Gets the parent body of the body. For example, a table cell body's parent body could be a header. If there isn't a
parent body, then this method will return an object with its `isNullObject` property set to `true`<!-- -->. For
further information, see [*OrNullObject methods and
properties](https://learn.microsoft.com/office/dev/add-ins/develop/application-specific-api-model#ornullobject-methods-and-properties)<!--
-->.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentBodyOrNullObject: Word.Body;'
return:
type: '<xref uid="word!Word.Body:class" />'
- name: parentContentControl
uid: 'word!Word.Body#parentContentControl:member'
package: word!
fullName: parentContentControl
summary: >-
Gets the content control that contains the body. Throws an `ItemNotFound` error if there isn't a parent content
control.
remarks: '\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentContentControl: Word.ContentControl;'
return:
type: '<xref uid="word!Word.ContentControl:class" />'
- name: parentContentControlOrNullObject
uid: 'word!Word.Body#parentContentControlOrNullObject:member'
package: word!
fullName: parentContentControlOrNullObject
summary: >-
Gets the content control that contains the body. If there isn't a parent content control, then this method will
return an object with its `isNullObject` property set to `true`<!-- -->. For further information, see
[*OrNullObject methods and
properties](https://learn.microsoft.com/office/dev/add-ins/develop/application-specific-api-model#ornullobject-methods-and-properties)<!--
-->.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentContentControlOrNullObject: Word.ContentControl;'
return:
type: '<xref uid="word!Word.ContentControl:class" />'
- name: parentSection
uid: 'word!Word.Body#parentSection:member'
package: word!
fullName: parentSection
summary: Gets the parent section of the body. Throws an `ItemNotFound` error if there isn't a parent section.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentSection: Word.Section;'
return:
type: '<xref uid="word!Word.Section:class" />'
- name: parentSectionOrNullObject
uid: 'word!Word.Body#parentSectionOrNullObject:member'
package: word!
fullName: parentSectionOrNullObject
summary: >-
Gets the parent section of the body. If there isn't a parent section, then this method will return an object with
its `isNullObject` property set to `true`<!-- -->. For further information, see [*OrNullObject methods and
properties](https://learn.microsoft.com/office/dev/add-ins/develop/application-specific-api-model#ornullobject-methods-and-properties)<!--
-->.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentSectionOrNullObject: Word.Section;'
return:
type: '<xref uid="word!Word.Section:class" />'
- name: style
uid: 'word!Word.Body#style:member'
package: word!
fullName: style
summary: >-
Specifies the style name for the body. Use this property for custom styles and localized style names. To use the
built-in styles that are portable between locales, see the "styleBuiltIn" property.
remarks: '\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'style: string;'
return:
type: string
- name: styleBuiltIn
uid: 'word!Word.Body#styleBuiltIn:member'
package: word!
fullName: styleBuiltIn
summary: >-
Specifies the built-in style name for the body. Use this property for built-in styles that are portable between
locales. To use custom styles or localized style names, see the "style" property.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: >-
styleBuiltIn: Word.BuiltInStyleName | "Other" | "Normal" | "Heading1" | "Heading2" | "Heading3" | "Heading4" |
"Heading5" | "Heading6" | "Heading7" | "Heading8" | "Heading9" | "Toc1" | "Toc2" | "Toc3" | "Toc4" | "Toc5" |
"Toc6" | "Toc7" | "Toc8" | "Toc9" | "FootnoteText" | "Header" | "Footer" | "Caption" | "FootnoteReference" |
"EndnoteReference" | "EndnoteText" | "Title" | "Subtitle" | "Hyperlink" | "Strong" | "Emphasis" | "NoSpacing" |
"ListParagraph" | "Quote" | "IntenseQuote" | "SubtleEmphasis" | "IntenseEmphasis" | "SubtleReference" |
"IntenseReference" | "BookTitle" | "Bibliography" | "TocHeading" | "TableGrid" | "PlainTable1" | "PlainTable2" |
"PlainTable3" | "PlainTable4" | "PlainTable5" | "TableGridLight" | "GridTable1Light" | "GridTable1Light_Accent1"
| "GridTable1Light_Accent2" | "GridTable1Light_Accent3" | "GridTable1Light_Accent4" | "GridTable1Light_Accent5"
| "GridTable1Light_Accent6" | "GridTable2" | "GridTable2_Accent1" | "GridTable2_Accent2" | "GridTable2_Accent3"
| "GridTable2_Accent4" | "GridTable2_Accent5" | "GridTable2_Accent6" | "GridTable3" | "GridTable3_Accent1" |
"GridTable3_Accent2" | "GridTable3_Accent3" | "GridTable3_Accent4" | "GridTable3_Accent5" | "GridTable3_Accent6"
| "GridTable4" | "GridTable4_Accent1" | "GridTable4_Accent2" | "GridTable4_Accent3" | "GridTable4_Accent4" |
"GridTable4_Accent5" | "GridTable4_Accent6" | "GridTable5Dark" | "GridTable5Dark_Accent1" |
"GridTable5Dark_Accent2" | "GridTable5Dark_Accent3" | "GridTable5Dark_Accent4" | "GridTable5Dark_Accent5" |
"GridTable5Dark_Accent6" | "GridTable6Colorful" | "GridTable6Colorful_Accent1" | "GridTable6Colorful_Accent2" |
"GridTable6Colorful_Accent3" | "GridTable6Colorful_Accent4" | "GridTable6Colorful_Accent5" |
"GridTable6Colorful_Accent6" | "GridTable7Colorful" | "GridTable7Colorful_Accent1" |
"GridTable7Colorful_Accent2" | "GridTable7Colorful_Accent3" | "GridTable7Colorful_Accent4" |
"GridTable7Colorful_Accent5" | "GridTable7Colorful_Accent6" | "ListTable1Light" | "ListTable1Light_Accent1" |
"ListTable1Light_Accent2" | "ListTable1Light_Accent3" | "ListTable1Light_Accent4" | "ListTable1Light_Accent5" |
"ListTable1Light_Accent6" | "ListTable2" | "ListTable2_Accent1" | "ListTable2_Accent2" | "ListTable2_Accent3" |
"ListTable2_Accent4" | "ListTable2_Accent5" | "ListTable2_Accent6" | "ListTable3" | "ListTable3_Accent1" |
"ListTable3_Accent2" | "ListTable3_Accent3" | "ListTable3_Accent4" | "ListTable3_Accent5" | "ListTable3_Accent6"
| "ListTable4" | "ListTable4_Accent1" | "ListTable4_Accent2" | "ListTable4_Accent3" | "ListTable4_Accent4" |
"ListTable4_Accent5" | "ListTable4_Accent6" | "ListTable5Dark" | "ListTable5Dark_Accent1" |
"ListTable5Dark_Accent2" | "ListTable5Dark_Accent3" | "ListTable5Dark_Accent4" | "ListTable5Dark_Accent5" |
"ListTable5Dark_Accent6" | "ListTable6Colorful" | "ListTable6Colorful_Accent1" | "ListTable6Colorful_Accent2" |
"ListTable6Colorful_Accent3" | "ListTable6Colorful_Accent4" | "ListTable6Colorful_Accent5" |
"ListTable6Colorful_Accent6" | "ListTable7Colorful" | "ListTable7Colorful_Accent1" |
"ListTable7Colorful_Accent2" | "ListTable7Colorful_Accent3" | "ListTable7Colorful_Accent4" |
"ListTable7Colorful_Accent5" | "ListTable7Colorful_Accent6";
return:
type: >-
<xref uid="word!Word.BuiltInStyleName:enum" /> | "Other" | "Normal" | "Heading1" | "Heading2" | "Heading3" |
"Heading4" | "Heading5" | "Heading6" | "Heading7" | "Heading8" | "Heading9" | "Toc1" | "Toc2" | "Toc3" |
"Toc4" | "Toc5" | "Toc6" | "Toc7" | "Toc8" | "Toc9" | "FootnoteText" | "Header" | "Footer" | "Caption" |
"FootnoteReference" | "EndnoteReference" | "EndnoteText" | "Title" | "Subtitle" | "Hyperlink" | "Strong" |
"Emphasis" | "NoSpacing" | "ListParagraph" | "Quote" | "IntenseQuote" | "SubtleEmphasis" | "IntenseEmphasis" |
"SubtleReference" | "IntenseReference" | "BookTitle" | "Bibliography" | "TocHeading" | "TableGrid" |
"PlainTable1" | "PlainTable2" | "PlainTable3" | "PlainTable4" | "PlainTable5" | "TableGridLight" |
"GridTable1Light" | "GridTable1Light_Accent1" | "GridTable1Light_Accent2" | "GridTable1Light_Accent3" |
"GridTable1Light_Accent4" | "GridTable1Light_Accent5" | "GridTable1Light_Accent6" | "GridTable2" |
"GridTable2_Accent1" | "GridTable2_Accent2" | "GridTable2_Accent3" | "GridTable2_Accent4" |
"GridTable2_Accent5" | "GridTable2_Accent6" | "GridTable3" | "GridTable3_Accent1" | "GridTable3_Accent2" |
"GridTable3_Accent3" | "GridTable3_Accent4" | "GridTable3_Accent5" | "GridTable3_Accent6" | "GridTable4" |
"GridTable4_Accent1" | "GridTable4_Accent2" | "GridTable4_Accent3" | "GridTable4_Accent4" |
"GridTable4_Accent5" | "GridTable4_Accent6" | "GridTable5Dark" | "GridTable5Dark_Accent1" |
"GridTable5Dark_Accent2" | "GridTable5Dark_Accent3" | "GridTable5Dark_Accent4" | "GridTable5Dark_Accent5" |
"GridTable5Dark_Accent6" | "GridTable6Colorful" | "GridTable6Colorful_Accent1" | "GridTable6Colorful_Accent2"
| "GridTable6Colorful_Accent3" | "GridTable6Colorful_Accent4" | "GridTable6Colorful_Accent5" |
"GridTable6Colorful_Accent6" | "GridTable7Colorful" | "GridTable7Colorful_Accent1" |
"GridTable7Colorful_Accent2" | "GridTable7Colorful_Accent3" | "GridTable7Colorful_Accent4" |
"GridTable7Colorful_Accent5" | "GridTable7Colorful_Accent6" | "ListTable1Light" | "ListTable1Light_Accent1" |
"ListTable1Light_Accent2" | "ListTable1Light_Accent3" | "ListTable1Light_Accent4" | "ListTable1Light_Accent5"
| "ListTable1Light_Accent6" | "ListTable2" | "ListTable2_Accent1" | "ListTable2_Accent2" |
"ListTable2_Accent3" | "ListTable2_Accent4" | "ListTable2_Accent5" | "ListTable2_Accent6" | "ListTable3" |
"ListTable3_Accent1" | "ListTable3_Accent2" | "ListTable3_Accent3" | "ListTable3_Accent4" |
"ListTable3_Accent5" | "ListTable3_Accent6" | "ListTable4" | "ListTable4_Accent1" | "ListTable4_Accent2" |
"ListTable4_Accent3" | "ListTable4_Accent4" | "ListTable4_Accent5" | "ListTable4_Accent6" | "ListTable5Dark" |
"ListTable5Dark_Accent1" | "ListTable5Dark_Accent2" | "ListTable5Dark_Accent3" | "ListTable5Dark_Accent4" |
"ListTable5Dark_Accent5" | "ListTable5Dark_Accent6" | "ListTable6Colorful" | "ListTable6Colorful_Accent1" |
"ListTable6Colorful_Accent2" | "ListTable6Colorful_Accent3" | "ListTable6Colorful_Accent4" |
"ListTable6Colorful_Accent5" | "ListTable6Colorful_Accent6" | "ListTable7Colorful" |
"ListTable7Colorful_Accent1" | "ListTable7Colorful_Accent2" | "ListTable7Colorful_Accent3" |
"ListTable7Colorful_Accent4" | "ListTable7Colorful_Accent5" | "ListTable7Colorful_Accent6"
- name: tables
uid: 'word!Word.Body#tables:member'
package: word!
fullName: tables
summary: Gets the collection of table objects in the body.
remarks: >-
\[ [API set: WordApi 1.3](/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/40-tables/table-cell-access.yaml
// Gets the content of the first cell in the first table.
await Word.run(async (context) => {
const firstCell = context.document.body.tables.getFirst().getCell(0, 0).body;
firstCell.load("text");
await context.sync();
console.log("First cell's text is: " + firstCell.text);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly tables: Word.TableCollection;'
return:
type: '<xref uid="word!Word.TableCollection:class" />'
- name: text
uid: 'word!Word.Body#text:member'
package: word!
fullName: text
summary: Gets the text of the body. Use the insertText method to insert text.
remarks: >-
\[ [API set: WordApi 1.1](/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-body.yaml
// Gets the text content of the body.
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the document body.
const body = context.document.body;
// Queue a command to load the text in document body.
body.load("text");
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("Body contents (text): " + body.text);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly text: string;'
return:
type: string
- name: type
uid: 'word!Word.Body#type:member'
package: word!
fullName: type
summary: >-
Gets the type of the body. The type can be 'MainDoc', 'Section', 'Header', 'Footer', or 'TableCell'. Additional
types ‘Footnote’, ‘Endnote’, and ‘NoteItem’ are supported in WordAPIOnline 1.1 and later.
remarks: >-
\[ [API set: WordApi 1.3](/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-footnotes.yaml
// Gets the referenced note's item type and body type, which are both "Footnote".
await Word.run(async (context) => {
const footnotes = context.document.body.footnotes;
footnotes.load("items");
await context.sync();
const referenceNumber = $("#input-reference").val();
const mark = (referenceNumber as number) - 1;
const item = footnotes.items[mark];
console.log(`Note type of footnote ${referenceNumber}: ${item.type}`);
item.body.load("type");
await context.sync();
console.log(`Body type of note: ${item.body.type}`);
});
```
isPreview: false
isDeprecated: false
syntax:
content: >-
readonly type: Word.BodyType | "Unknown" | "MainDoc" | "Section" | "Header" | "Footer" | "TableCell" |
"Footnote" | "Endnote" | "NoteItem";
return:
type: >-
<xref uid="word!Word.BodyType:enum" /> | "Unknown" | "MainDoc" | "Section" | "Header" | "Footer" | "TableCell"
| "Footnote" | "Endnote" | "NoteItem"
methods:
- name: clear()
uid: 'word!Word.Body#clear:member(1)'
package: word!
fullName: clear()
summary: Clears the contents of the body object. The user can perform the undo operation on the cleared content.
remarks: >-
\[ [API set: WordApi 1.1](/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-body.yaml
// Clears out the content from the document body.
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the document body.
const body = context.document.body;
// Queue a command to clear the contents of the body.
body.clear();
console.log("Cleared the body contents.");
});
// The Silly stories add-in sample shows how the clear method can be used to clear the contents of a document.
// https://aka.ms/sillystorywordaddin
```
isPreview: false
isDeprecated: false
syntax:
content: 'clear(): void;'
return:
type: void
description: ''
- name: getComments()
uid: 'word!Word.Body#getComments:member(1)'
package: word!
fullName: getComments()
summary: Gets comments associated with the body.
remarks: >-
\[ [API set: WordApi 1.4](/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-comments.yaml
// Gets the comments in the document body.
await Word.run(async (context) => {
const comments = context.document.body.getComments();
// Load objects to log in the console.
comments.load();
await context.sync();
console.log("All comments:", comments);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getComments(): Word.CommentCollection;'
return:
type: '<xref uid="word!Word.CommentCollection:class" />'
description: ''
- name: getContentControls(options)
uid: 'word!Word.Body#getContentControls:member(1)'
package: word!
fullName: getContentControls(options)
summary: Gets the currently supported content controls in the body.
remarks: >-
\[ [API set: WordApi 1.5](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
Important: If specific types are provided in the options parameter, only content controls of supported types are
returned. Be aware that an exception will be thrown on using methods of a generic
[Word.ContentControl](xref:word!Word.ContentControl:class) that aren't relevant for the specific type. With time,
additional types of content controls may be supported. Therefore, your add-in should request and handle specific
types of content controls.
isPreview: false
isDeprecated: false
syntax:
content: 'getContentControls(options?: Word.ContentControlOptions): Word.ContentControlCollection;'
parameters:
- id: options
description: Optional. Options that define which content controls are returned.
type: '<xref uid="word!Word.ContentControlOptions:interface" />'
return:
type: '<xref uid="word!Word.ContentControlCollection:class" />'
description: ''
- name: getHtml()
uid: 'word!Word.Body#getHtml:member(1)'
package: word!
fullName: getHtml()
summary: >-
Gets an HTML representation of the body object. When rendered in a web page or HTML viewer, the formatting will be
a close, but not exact, match for of the formatting of the document. This method doesn't return the exact same
HTML for the same document on different platforms (Windows, Mac, Word on the web, etc.). If you need exact
fidelity, or consistency across platforms, use `Body.getOoxml()` and convert the returned XML to HTML.
remarks: >-
\[ [API set: WordApi 1.1](/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-body.yaml
// Gets the HTML that represents the content of the body.
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the document body.
const body = context.document.body;
// Queue a command to get the HTML contents of the body.
const bodyHTML = body.getHtml();
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("Body contents (HTML): " + bodyHTML.value);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getHtml(): OfficeExtension.ClientResult<string>;'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string>'
description: ''
- name: getOoxml()
uid: 'word!Word.Body#getOoxml:member(1)'
package: word!
fullName: getOoxml()
summary: Gets the OOXML (Office Open XML) representation of the body object.
remarks: >-
\[ [API set: WordApi 1.1](/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-body.yaml
// Gets the OOXML that represents the content of the body.
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the document body.
const body = context.document.body;
// Queue a command to get the OOXML contents of the body.
const bodyOOXML = body.getOoxml();
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("Body contents (OOXML): " + bodyOOXML.value);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getOoxml(): OfficeExtension.ClientResult<string>;'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string>'
description: ''
- name: getRange(rangeLocation)
uid: 'word!Word.Body#getRange:member(1)'
package: word!
fullName: getRange(rangeLocation)
summary: 'Gets the whole body, or the starting or ending point of the body, as a range.'
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: >-
getRange(rangeLocation?: Word.RangeLocation.whole | Word.RangeLocation.start | Word.RangeLocation.end |
Word.RangeLocation.after | Word.RangeLocation.content | "Whole" | "Start" | "End" | "After" | "Content"):
Word.Range;
parameters:
- id: rangeLocation
description: 'Optional. The range location must be ''Whole'', ''Start'', ''End'', ''After'', or ''Content''.'
type: >-
<xref uid="word!Word.RangeLocation.whole:member" /> | <xref uid="word!Word.RangeLocation.start:member" /> |
<xref uid="word!Word.RangeLocation.end:member" /> | <xref uid="word!Word.RangeLocation.after:member" /> |
<xref uid="word!Word.RangeLocation.content:member" /> | "Whole" | "Start" | "End" | "After" | "Content"
return:
type: '<xref uid="word!Word.Range:class" />'
description: ''
- name: getReviewedText(changeTrackingVersion)
uid: 'word!Word.Body#getReviewedText:member(1)'
package: word!
fullName: getReviewedText(changeTrackingVersion)
summary: Gets reviewed text based on ChangeTrackingVersion selection.
remarks: '\[ [API set: WordApi 1.4](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getReviewedText(changeTrackingVersion?: Word.ChangeTrackingVersion): OfficeExtension.ClientResult<string>;'
parameters:
- id: changeTrackingVersion
description: Optional. The value must be 'Original' or 'Current'. The default is 'Current'.
type: '<xref uid="word!Word.ChangeTrackingVersion:enum" />'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string>'
description: ''
- name: getReviewedText(changeTrackingVersionString)
uid: 'word!Word.Body#getReviewedText:member(2)'
package: word!
fullName: getReviewedText(changeTrackingVersionString)
summary: Gets reviewed text based on ChangeTrackingVersion selection.
remarks: '\[ [API set: WordApi 1.4](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getReviewedText(changeTrackingVersionString?: "Original" | "Current"): OfficeExtension.ClientResult<string>;'
parameters:
- id: changeTrackingVersionString
description: Optional. The value must be 'Original' or 'Current'. The default is 'Current'.
type: '"Original" | "Current"'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string>'
description: ''
- name: getTrackedChanges()
uid: 'word!Word.Body#getTrackedChanges:member(1)'
package: word!
fullName: getTrackedChanges()
summary: Gets the collection of the TrackedChange objects in the body.
remarks: >-
\[ [API set: WordApi 1.6](/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-tracked-changes.yaml
// Gets all tracked changes.
await Word.run(async (context) => {
const body = context.document.body;
const trackedChanges = body.getTrackedChanges();
trackedChanges.load();
await context.sync();
console.log(trackedChanges);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getTrackedChanges(): Word.TrackedChangeCollection;'
return:
type: '<xref uid="word!Word.TrackedChangeCollection:class" />'
description: ''
- name: 'insertBreak(breakType, insertLocation)'
uid: 'word!Word.Body#insertBreak:member(1)'
package: word!
fullName: 'insertBreak(breakType, insertLocation)'
summary: Inserts a break at the specified location in the main document.
remarks: >-
\[ [API set: WordApi 1.1](/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-body.yaml
// Inserts a page break at the beginning of the document.
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the document body.
const body = context.document.body;
// Queue a command to insert a page break at the start of the document body.
body.insertBreak(Word.BreakType.page, Word.InsertLocation.start);
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("Added a page break at the start of the document body.");
});
```
isPreview: false
isDeprecated: false
syntax:
content: >-
insertBreak(breakType: Word.BreakType | "Page" | "Next" | "SectionNext" | "SectionContinuous" | "SectionEven" |
"SectionOdd" | "Line", insertLocation: Word.InsertLocation.start | Word.InsertLocation.end | "Start" | "End"):
void;
parameters: