-
Notifications
You must be signed in to change notification settings - Fork 62
/
word.application.yml
187 lines (160 loc) · 6.67 KB
/
word.application.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
### YamlMime:TSType
name: Word.Application
uid: 'word!Word.Application:class'
package: word!
fullName: Word.Application
summary: Represents the application object.
remarks: '\[ [API set: WordApi 1.3](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: class
properties:
- name: context
uid: 'word!Word.Application#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" />'
methods:
- name: createDocument(base64File)
uid: 'word!Word.Application#createDocument:member(1)'
package: word!
fullName: createDocument(base64File)
summary: Creates a new document by using an optional Base64-encoded .docx file.
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/insert-external-document.yaml
// Updates the text of the current document with the text from another document passed in as a Base64-encoded
string.
await Word.run(async (context) => {
// Use the Base64-encoded string representation of the selected .docx file.
const externalDoc = context.application.createDocument(externalDocument);
await context.sync();
const externalDocBody = externalDoc.body;
externalDocBody.load("text");
await context.sync();
// Insert the external document's text at the beginning of the current document's body.
const externalDocBodyText = externalDocBody.text;
const currentDocBody = context.document.body;
currentDocBody.insertText(externalDocBodyText, Word.InsertLocation.start);
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'createDocument(base64File?: string): Word.DocumentCreated;'
parameters:
- id: base64File
description: Optional. The Base64-encoded .docx file. The default value is null.
type: string
return:
type: '<xref uid="word!Word.DocumentCreated:class" />'
description: ''
- name: newObject(context)
uid: 'word!Word.Application.newObject:member(1)'
package: word!
fullName: newObject(context)
summary: Create a new instance of Word.Application object
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'static newObject(context: OfficeExtension.ClientRequestContext): Word.Application;'
parameters:
- id: context
description: ''
type: '<xref uid="office!OfficeExtension.ClientRequestContext:class" />'
return:
type: '<xref uid="word!Word.Application:class" />'
description: ''
- name: openDocument(filePath)
uid: 'word!Word.Application#openDocument:member(1)'
package: word!
fullName: openDocument(filePath)
summary: >-
Opens a document and displays it in a new tab or window. The following are examples for the various supported
clients and platforms.
- Remote or cloud location example: `https://microsoft.sharepoint.com/some/path/Document.docx`
- Local location examples for Windows: `C:\\Users\\Someone\\Documents\\Document.docx` (includes required escaped
backslashes), `file://mycomputer/myfolder/Document.docx`
- Local location example for Mac and iOS: `/User/someone/document.docx`
remarks: '\[ [API set: WordApi 1.6](/javascript/api/requirement-sets/word/word-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'openDocument(filePath: string): void;'
parameters:
- id: filePath
description: >-
Required. The absolute path of the .docx file. Word on the web only supports remote (cloud) locations, while
Word on Windows, on Mac, and on iOS support local and remote locations.
type: string
return:
type: void
description: ''
- name: retrieveStylesFromBase64(base64File)
uid: 'word!Word.Application#retrieveStylesFromBase64:member(1)'
package: word!
fullName: retrieveStylesFromBase64(base64File)
summary: Parse styles from template Base64 file and return JSON format of retrieved styles as a string.
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/get-external-styles.yaml
// Gets style info from another document passed in as a Base64-encoded string.
await Word.run(async (context) => {
const retrievedStyles = context.application.retrieveStylesFromBase64(externalDocument);
await context.sync();
console.log("Styles from the other document:", retrievedStyles.value);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'retrieveStylesFromBase64(base64File: string): OfficeExtension.ClientResult<string>;'
parameters:
- id: base64File
description: Required. The template file.
type: string
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string>'
description: ''
- name: toJSON()
uid: 'word!Word.Application#toJSON:member(1)'
package: word!
fullName: toJSON()
summary: >-
Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to
`JSON.stringify()`<!-- -->. (`JSON.stringify`<!-- -->, in turn, calls the `toJSON` method of the object that is
passed to it.) Whereas the original Word.Application object is an API object, the `toJSON` method returns a plain
JavaScript object (typed as `Word.Interfaces.ApplicationData`<!-- -->) that contains shallow copies of any loaded
child properties from the original object.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: |-
toJSON(): {
[key: string]: string;
};
return:
type: |-
{
[key: string]: string;
}
description: ''
extends: '<xref uid="office!OfficeExtension.ClientObject:class" />'