-
Notifications
You must be signed in to change notification settings - Fork 63
/
word.range.yml
1781 lines (1602 loc) · 77.4 KB
/
word.range.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.Range
uid: 'word!Word.Range:class'
package: word!
fullName: Word.Range
summary: Represents a contiguous area in a 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-comments.yaml
// Gets the range of the first comment in the selected content.
await Word.run(async (context) => {
const comment: Word.Comment = context.document.getSelection().getComments().getFirstOrNullObject();
comment.load("contentRange");
const range: Word.Range = comment.getRange();
range.load("text");
await context.sync();
if (comment.isNullObject) {
console.warn("No comments in the selection, so no range to get.");
return;
}
console.log(`Comment location: ${range.text}`);
const contentRange: Word.CommentContentRange = comment.contentRange;
console.log("Comment content range:", contentRange);
});
```
isPreview: false
isDeprecated: false
type: class
properties:
- name: contentControls
uid: 'word!Word.Range#contentControls:member'
package: word!
fullName: contentControls
summary: Gets the collection of content control objects in the range.
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.Range#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: fields
uid: 'word!Word.Range#fields:member'
package: word!
fullName: fields
summary: Gets the collection of field objects in the range.
remarks: '\[ [API set: WordApi 1.4](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly fields: Word.FieldCollection;'
return:
type: '<xref uid="word!Word.FieldCollection:class" />'
- name: font
uid: 'word!Word.Range#font:member'
package: word!
fullName: font
summary: 'Gets the text format of the range. 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) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly font: Word.Font;'
return:
type: '<xref uid="word!Word.Font:class" />'
- name: hyperlink
uid: 'word!Word.Range#hyperlink:member'
package: word!
fullName: hyperlink
summary: >-
Gets the first hyperlink in the range, or sets a hyperlink on the range. All hyperlinks in the range are deleted
when you set a new hyperlink on the range. Use a '\#' to separate the address part from the optional location
part.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'hyperlink: string;'
return:
type: string
- name: inlinePictures
uid: 'word!Word.Range#inlinePictures:member'
package: word!
fullName: inlinePictures
summary: Gets the collection of inline picture objects in the range.
remarks: '\[ [API set: WordApi 1.2](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly inlinePictures: Word.InlinePictureCollection;'
return:
type: '<xref uid="word!Word.InlinePictureCollection:class" />'
- name: isEmpty
uid: 'word!Word.Range#isEmpty:member'
package: word!
fullName: isEmpty
summary: Checks whether the range length is zero.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly isEmpty: boolean;'
return:
type: boolean
- name: lists
uid: 'word!Word.Range#lists:member'
package: word!
fullName: lists
summary: Gets the collection of list objects in the range.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly lists: Word.ListCollection;'
return:
type: '<xref uid="word!Word.ListCollection:class" />'
- name: paragraphs
uid: 'word!Word.Range#paragraphs:member'
package: word!
fullName: paragraphs
summary: Gets the collection of paragraph objects in the range.
remarks: >-
\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
Important: For requirement sets 1.1 and 1.2, paragraphs in tables wholly contained within this range aren't
returned. From requirement set 1.3, paragraphs in such tables are also returned.
isPreview: false
isDeprecated: false
syntax:
content: 'readonly paragraphs: Word.ParagraphCollection;'
return:
type: '<xref uid="word!Word.ParagraphCollection:class" />'
- name: parentBody
uid: 'word!Word.Range#parentBody:member'
package: word!
fullName: parentBody
summary: Gets the parent body of the range.
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: parentContentControl
uid: 'word!Word.Range#parentContentControl:member'
package: word!
fullName: parentContentControl
summary: >-
Gets the currently supported content control that contains the range. 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) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml
// Toggles the isChecked property of the first checkbox content control found in the selection.
await Word.run(async (context) => {
const selectedRange: Word.Range = context.document.getSelection();
let selectedContentControl = selectedRange
.getContentControls({
types: [Word.ContentControlType.checkBox]
})
.getFirstOrNullObject();
selectedContentControl.load("id,checkboxContentControl/isChecked");
await context.sync();
if (selectedContentControl.isNullObject) {
const parentContentControl: Word.ContentControl = selectedRange.parentContentControl;
parentContentControl.load("id,type,checkboxContentControl/isChecked");
await context.sync();
if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) {
console.warn("No checkbox content control is currently selected.");
return;
} else {
selectedContentControl = parentContentControl;
}
}
const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked;
console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`);
selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore;
selectedContentControl.load("id,checkboxContentControl/isChecked");
await context.sync();
console.log(
"isChecked state after:",
`id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}`
);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentContentControl: Word.ContentControl;'
return:
type: '<xref uid="word!Word.ContentControl:class" />'
- name: parentContentControlOrNullObject
uid: 'word!Word.Range#parentContentControlOrNullObject:member'
package: word!
fullName: parentContentControlOrNullObject
summary: >-
Gets the currently supported content control that contains the range. 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: parentTable
uid: 'word!Word.Range#parentTable:member'
package: word!
fullName: parentTable
summary: Gets the table that contains the range. Throws an `ItemNotFound` error if it isn't contained in a table.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentTable: Word.Table;'
return:
type: '<xref uid="word!Word.Table:class" />'
- name: parentTableCell
uid: 'word!Word.Range#parentTableCell:member'
package: word!
fullName: parentTableCell
summary: Gets the table cell that contains the range. Throws an `ItemNotFound` error if it isn't contained in a table cell.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly parentTableCell: Word.TableCell;'
return:
type: '<xref uid="word!Word.TableCell:class" />'
- name: parentTableCellOrNullObject
uid: 'word!Word.Range#parentTableCellOrNullObject:member'
package: word!
fullName: parentTableCellOrNullObject
summary: >-
Gets the table cell that contains the range. If it isn't contained in a table cell, 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 parentTableCellOrNullObject: Word.TableCell;'
return:
type: '<xref uid="word!Word.TableCell:class" />'
- name: parentTableOrNullObject
uid: 'word!Word.Range#parentTableOrNullObject:member'
package: word!
fullName: parentTableOrNullObject
summary: >-
Gets the table that contains the range. If it isn't contained in a table, 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 parentTableOrNullObject: Word.Table;'
return:
type: '<xref uid="word!Word.Table:class" />'
- name: style
uid: 'word!Word.Range#style:member'
package: word!
fullName: style
summary: >-
Specifies the style name for the range. 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.Range#styleBuiltIn:member'
package: word!
fullName: styleBuiltIn
summary: >-
Specifies the built-in style name for the range. 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) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml
await Word.run(async (context) => {
const header: Word.Range = context.document.body.insertText("This is a sample Heading 1 Title!!\n",
"Start" /*this means at the beginning of the body */);
header.styleBuiltIn = Word.BuiltInStyleName.heading1;
await context.sync();
});
```
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.Range#tables:member'
package: word!
fullName: tables
summary: Gets the collection of table objects in the range.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly tables: Word.TableCollection;'
return:
type: '<xref uid="word!Word.TableCollection:class" />'
- name: text
uid: 'word!Word.Range#text:member'
package: word!
fullName: text
summary: Gets the text of the range.
remarks: '\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly text: string;'
return:
type: string
methods:
- name: clear()
uid: 'word!Word.Range#clear:member(1)'
package: word!
fullName: clear()
summary: Clears the contents of the range 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
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Queue a command to get the current selection and then
// create a proxy range object with the results.
const range = context.document.getSelection();
// Queue a command to clear the contents of the proxy range object.
range.clear();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Cleared the selection (range object)');
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'clear(): void;'
return:
type: void
description: ''
- name: compareLocationWith(range)
uid: 'word!Word.Range#compareLocationWith:member(1)'
package: word!
fullName: compareLocationWith(range)
summary: Compares this range's location with another range's location.
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/35-ranges/compare-location.yaml
// Compares the location of one paragraph in relation to another paragraph.
await Word.run(async (context) => {
const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs;
paragraphs.load("items");
await context.sync();
const firstParagraphAsRange: Word.Range = paragraphs.items[0].getRange();
const secondParagraphAsRange: Word.Range = paragraphs.items[1].getRange();
const comparedLocation = firstParagraphAsRange.compareLocationWith(secondParagraphAsRange);
await context.sync();
const locationValue: Word.LocationRelation = comparedLocation.value;
console.log(`Location of the first paragraph in relation to the second paragraph: ${locationValue}`);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'compareLocationWith(range: Word.Range): OfficeExtension.ClientResult<Word.LocationRelation>;'
parameters:
- id: range
description: Required. The range to compare with this range.
type: '<xref uid="word!Word.Range:class" />'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><<xref uid="word!Word.LocationRelation:enum" />>'
description: ''
- name: delete()
uid: 'word!Word.Range#delete:member(1)'
package: word!
fullName: delete()
summary: Deletes the range and its content from the document.
remarks: |-
\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
#### Examples
```TypeScript
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Queue a command to get the current selection and then
// create a proxy range object with the results.
const range = context.document.getSelection();
// Queue a command to delete the range object.
range.delete();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Deleted the selection (range object)');
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'delete(): void;'
return:
type: void
description: ''
- name: expandTo(range)
uid: 'word!Word.Range#expandTo:member(1)'
package: word!
fullName: expandTo(range)
summary: >-
Returns a new range that extends from this range in either direction to cover another range. This range isn't
changed. Throws an `ItemNotFound` error if the two ranges do not have a union.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'expandTo(range: Word.Range): Word.Range;'
parameters:
- id: range
description: Required. Another range.
type: '<xref uid="word!Word.Range:class" />'
return:
type: '<xref uid="word!Word.Range:class" />'
description: ''
- name: expandToOrNullObject(range)
uid: 'word!Word.Range#expandToOrNullObject:member(1)'
package: word!
fullName: expandToOrNullObject(range)
summary: >-
Returns a new range that extends from this range in either direction to cover another range. This range isn't
changed. If the two ranges don't have a union, 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: 'expandToOrNullObject(range: Word.Range): Word.Range;'
parameters:
- id: range
description: Required. Another range.
type: '<xref uid="word!Word.Range:class" />'
return:
type: '<xref uid="word!Word.Range:class" />'
description: ''
- name: 'getBookmarks(includeHidden, includeAdjacent)'
uid: 'word!Word.Range#getBookmarks:member(1)'
package: word!
fullName: 'getBookmarks(includeHidden, includeAdjacent)'
summary: >-
Gets the names all bookmarks in or overlapping the range. A bookmark is hidden if its name starts with the
underscore character.
remarks: '\[ [API set: WordApi 1.4](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getBookmarks(includeHidden?: boolean, includeAdjacent?: boolean): OfficeExtension.ClientResult<string[]>;'
parameters:
- id: includeHidden
description: >-
Optional. Indicates whether to include hidden bookmarks. Default is false which indicates that the hidden
bookmarks are excluded.
type: boolean
- id: includeAdjacent
description: >-
Optional. Indicates whether to include bookmarks that are adjacent to the range. Default is false which
indicates that the adjacent bookmarks are excluded.
type: boolean
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string[]>'
description: ''
- name: getComments()
uid: 'word!Word.Range#getComments:member(1)'
package: word!
fullName: getComments()
summary: Gets comments associated with the range.
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 selected content.
await Word.run(async (context) => {
const comments: Word.CommentCollection = context.document.getSelection().getComments();
// Load objects to log in the console.
comments.load();
await context.sync();
console.log("Comments:", comments);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getComments(): Word.CommentCollection;'
return:
type: '<xref uid="word!Word.CommentCollection:class" />'
description: ''
- name: getHtml()
uid: 'word!Word.Range#getHtml:member(1)'
package: word!
fullName: getHtml()
summary: >-
Gets an HTML representation of the range 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 `Range.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
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Queue a command to get the current selection and then
// create a proxy range object with the results.
const range = context.document.getSelection();
// Queue a command to get the HTML of the current selection.
const html = range.getHtml();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('The HTML read from the document was: ' + html.value);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getHtml(): OfficeExtension.ClientResult<string>;'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string>'
description: ''
- name: getHyperlinkRanges()
uid: 'word!Word.Range#getHyperlinkRanges:member(1)'
package: word!
fullName: getHyperlinkRanges()
summary: Gets hyperlink child ranges within the range.
remarks: |-
\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
#### Examples
```TypeScript
await Word.run(async (context) => {
// Get the entire document body.
const bodyRange = context.document.body.getRange(Word.RangeLocation.whole);
// Get all the ranges that only consist of hyperlinks.
const hyperLinks = bodyRange.getHyperlinkRanges();
hyperLinks.load("hyperlink");
await context.sync();
// Log each hyperlink.
hyperLinks.items.forEach((linkRange) => {
console.log(linkRange.hyperlink);
});
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getHyperlinkRanges(): Word.RangeCollection;'
return:
type: '<xref uid="word!Word.RangeCollection:class" />'
description: ''
- name: 'getNextTextRange(endingMarks, trimSpacing)'
uid: 'word!Word.Range#getNextTextRange:member(1)'
package: word!
fullName: 'getNextTextRange(endingMarks, trimSpacing)'
summary: >-
Gets the next text range by using punctuation marks and/or other ending marks. Throws an `ItemNotFound` error if
this text range is the last one.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getNextTextRange(endingMarks: string[], trimSpacing?: boolean): Word.Range;'
parameters:
- id: endingMarks
description: Required. The punctuation marks and/or other ending marks as an array of strings.
type: 'string[]'
- id: trimSpacing
description: >-
Optional. Indicates whether to trim spacing characters (spaces, tabs, column breaks, and paragraph end
marks) from the start and end of the returned range. Default is false which indicates that spacing
characters at the start and end of the range are included.
type: boolean
return:
type: '<xref uid="word!Word.Range:class" />'
description: ''
- name: 'getNextTextRangeOrNullObject(endingMarks, trimSpacing)'
uid: 'word!Word.Range#getNextTextRangeOrNullObject:member(1)'
package: word!
fullName: 'getNextTextRangeOrNullObject(endingMarks, trimSpacing)'
summary: >-
Gets the next text range by using punctuation marks and/or other ending marks. If this text range is the last one,
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: 'getNextTextRangeOrNullObject(endingMarks: string[], trimSpacing?: boolean): Word.Range;'
parameters:
- id: endingMarks
description: Required. The punctuation marks and/or other ending marks as an array of strings.
type: 'string[]'
- id: trimSpacing
description: >-
Optional. Indicates whether to trim spacing characters (spaces, tabs, column breaks, and paragraph end
marks) from the start and end of the returned range. Default is false which indicates that spacing
characters at the start and end of the range are included.
type: boolean
return:
type: '<xref uid="word!Word.Range:class" />'
description: ''
- name: getOoxml()
uid: 'word!Word.Range#getOoxml:member(1)'
package: word!
fullName: getOoxml()
summary: Gets the OOXML representation of the range object.
remarks: |-
\[ [API set: WordApi 1.1](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
#### Examples
```TypeScript
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Queue a command to get the current selection and then
// create a proxy range object with the results.
const range = context.document.getSelection();
// Queue a command to get the OOXML of the current selection.
const ooxml = range.getOoxml();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('The OOXML read from the document was: ' + ooxml.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.Range#getRange:member(1)'
package: word!
fullName: getRange(rangeLocation)
summary: 'Clones the range, or gets the starting or ending point of the range as a new 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.Range#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) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-change-tracking.yaml
// Gets the reviewed text.
await Word.run(async (context) => {
const range: Word.Range = context.document.getSelection();
const before = range.getReviewedText(Word.ChangeTrackingVersion.original);
const after = range.getReviewedText(Word.ChangeTrackingVersion.current);
await context.sync();
console.log("Reviewed text (before):", before.value, "Reviewed text (after):", after.value);
});
```
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.Range#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: 'getTextRanges(endingMarks, trimSpacing)'
uid: 'word!Word.Range#getTextRanges:member(1)'
package: word!
fullName: 'getTextRanges(endingMarks, trimSpacing)'
summary: Gets the text child ranges in the range by using punctuation marks and/or other ending marks.
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/25-paragraph/get-paragraph-on-insertion-point.yaml
await Word.run(async (context) => {
// Get the complete sentence (as range) associated with the insertion point.
const sentences: Word.RangeCollection = context.document
.getSelection()
.getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/);
sentences.load("$none");
await context.sync();
// Expand the range to the end of the paragraph to get all the complete sentences.
const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0]
.getRange()
.expandTo(
context.document
.getSelection()
.paragraphs.getFirst()
.getRange(Word.RangeLocation.end)
)
.getTextRanges(["."], false /* Don't trim spaces*/);
sentencesToTheEndOfParagraph.load("text");
await context.sync();
for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) {
console.log(sentencesToTheEndOfParagraph.items[i].text);
}
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getTextRanges(endingMarks: string[], trimSpacing?: boolean): Word.RangeCollection;'
parameters:
- id: endingMarks
description: Required. The punctuation marks and/or other ending marks as an array of strings.
type: 'string[]'
- id: trimSpacing
description: >-
Optional. Indicates whether to trim spacing characters (spaces, tabs, column breaks, and paragraph end
marks) from the start and end of the ranges returned in the range collection. Default is false which
indicates that spacing characters at the start and end of the ranges are included in the range collection.
type: boolean
return:
type: '<xref uid="word!Word.RangeCollection:class" />'
description: ''
- name: insertBookmark(name)
uid: 'word!Word.Range#insertBookmark:member(1)'
package: word!
fullName: insertBookmark(name)
summary: 'Inserts a bookmark on the range. If a bookmark of the same name exists somewhere, it is deleted first.'
remarks: >-
\[ [API set: WordApi 1.4](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]
Note: The conditions of inserting a bookmark are similar to doing so in the Word UI. To learn more about managing
bookmarks in the Word UI, see [Add or delete bookmarks in a Word document or Outlook
message](https://support.microsoft.com/office/f68d781f-0150-4583-a90e-a4009d99c2a0)<!-- -->.
isPreview: false
isDeprecated: false
syntax:
content: 'insertBookmark(name: string): void;'
parameters:
- id: name
description: >-
Required. The case-insensitive bookmark name. Only alphanumeric and underscore characters are supported. It
must begin with a letter but if you want to tag the bookmark as hidden, then start the name with an
underscore character. Names can't be longer than 40 characters.
type: string
return:
type: void
description: ''
- name: 'insertBreak(breakType, insertLocation)'