You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
body.insertParagraph("One more paragraph.", "Start");
134
+
body.insertParagraph("Inserting another paragraph.", "Start");
135
+
body.insertParagraph(
136
+
"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.",
137
+
"Start"
138
+
);
139
+
body.paragraphs
140
+
.getLast()
141
+
.insertText(
142
+
"Use add-in commands to extend the Word UI and launch task panes that run JavaScript that interacts with the content in a Word document. Any code that you can run in a browser can run in a Word add-in. Add-ins that interact with content in a Word document create requests to act on Word objects and synchronize object state.",
143
+
"Replace"
144
+
);
145
+
});
146
+
}
147
+
148
+
// Default helper for invoking an action and handling errors.
149
+
async function tryCatch(callback) {
150
+
try {
151
+
await callback();
152
+
} catch (error) {
153
+
// Note: In a production add-in, you'd want to notify the user through your add-in's UI.
154
+
if (error.code === Word.ErrorCodes.itemNotFound) {
155
+
console.warn("No combo box content control is currently selected.");
156
+
} else {
157
+
console.error(error);
158
+
}
159
+
}
160
+
}
161
+
language: typescript
162
+
template:
163
+
content: |-
164
+
<section class="ms-font-m">
165
+
This sample demonstrates how to insert, change, and delete combo box content controls.
166
+
</section>
167
+
168
+
<section class="setup ms-font-m">
169
+
<h3>Set up</h3>
170
+
<button id="setup" class="ms-Button">
171
+
<span class="ms-Button-label">Setup</span>
172
+
</button>
173
+
</section>
174
+
175
+
<section class="samples ms-font-m">
176
+
<h3>Try it out</h3>
177
+
<p>
178
+
<span class="ms-font-m">Insert a combo box content control after selected text.</span>
179
+
<button id="insert-control" class="ms-Button">
180
+
<span class="ms-Button-label">Insert</span>
181
+
</button>
182
+
</p>
183
+
<p>
184
+
<div class="ms-font-m">Add a unique list item to the first combo box content control found in your selected
185
+
content.
186
+
</div>
187
+
<label><b>Item to add</b>:</label>
188
+
<input id="item-to-add">
189
+
<button id="add-item" class="ms-Button">
190
+
<span class=ms-Button-label>Add item</span>
191
+
</button>
192
+
</p>
193
+
<p>
194
+
<span class="ms-font-m">Delete all list items from the first combo box content control found in your selected content.</span>
195
+
<button id="delete-list" class="ms-Button">
196
+
<span class=ms-Button-label>Delete list</span>
197
+
</button>
198
+
</p>
199
+
<p>
200
+
<span class="ms-font-m">Delete the first combo box content control found in your selected content.</span>
0 commit comments