Skip to content

Commit acb0c4c

Browse files
author
github-actions
committed
Merge branch 'main' into live
2 parents d27168f + 0b30088 commit acb0c4c

File tree

5 files changed

+217
-12
lines changed

5 files changed

+217
-12
lines changed

docs/develop/convert-xml-to-json-manifest.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.localizationpriority: medium
1111
To add Teams capabilities to an add-in that uses the add-in only manifest, or to just future proof the add-in, you need to convert it to use the unified manifest for Microsoft 365.
1212

1313
> [!NOTE]
14-
>
14+
>
1515
> - Projects created in Visual Studio, as distinct from Visual Studio Code, can't be converted at this time.
1616
> - If you [created the project with Teams Toolkit](teams-toolkit-overview.md) or with the "unified manifest" option in the [Yeoman generator for Office Add-ins (Yo Office)](yeoman-generator-overview.md), it already uses the unified manifest.
1717
@@ -26,7 +26,7 @@ There are three basic tasks to converting an add-in project from the add-in only
2626
[!INCLUDE [non-unified manifest clients note](../includes/non-unified-manifest-clients.md)]
2727

2828
> [!NOTE]
29-
>
29+
>
3030
> - Add-ins that use the unified manifest can be sideloaded only on Office Version 2304 (Build 16320.20000) or later.
3131
> - Projects created in Visual Studio, as distinct from Visual Studio Code, can't be converted at this time.
3232
> - If you [created the project with Teams Toolkit](teams-toolkit-overview.md) or with the "unified manifest" option in the [Office Yeoman Generator](yeoman-generator-overview.md), it already uses the unified manifest.
@@ -41,12 +41,12 @@ To avoid conflicts with UI control names and other problems, be sure the existin
4141

4242
### Ensure that you have two special image files
4343

44-
If your add-in only manifest doesn't already have both **\<IconUrl\>** and **\<HighResolutionIconUrl\>** (in that order) elements, then add them just below the **\<Description\>** element. The values of the **DefaultValue** attribute should be the full URLs of image files. The images must be a specified size as shown in the following table.
44+
If your add-in only manifest doesn't already have both **\<IconUrl\>** and **\<HighResolutionIconUrl\>** (in that order) elements, then add them just below the **\<Description\>** element. The values of the **DefaultValue** attribute should be the full URLs of image files. The images must be a specified size as shown in the following table.
4545

4646
|Office application|\<IconUrl\>|\<HighResolutionIconUrl\>|
4747
|:---------------|:---------------|:---------------|
4848
|Outlook|64x64 pixels|128x128 pixels|
49-
|All other Office</br>applications|32x32 pixels|64x64 pixels|
49+
|All other Office</br>applications|32x32 pixels|64x64 pixels|
5050

5151
The following markup is an example.
5252

@@ -72,7 +72,7 @@ The following markup is an example.
7272

7373
1. Be sure that the domain segment of the add-in's URLs in the manifest are pointing to `https://localhost:3000`.
7474

75-
1. If your manifest has any **\<FunctionName\>** elements, make sure their values have fewer than 65 characters.
75+
1. If your manifest has any **\<FunctionName\>** elements, make sure their values have fewer than 65 characters.
7676

7777
> [!IMPORTANT]
7878
> The value of this element must exactly match the name of an action that's mapped to a function in a JavaScript or TypeScript file with the [Office.actions.associate](/javascript/api/office/office.actions#office-office-actions-associate-member(1)) function. If you change it in the manifest, be sure to change it in the `actionId` parameter passed to `associate()` too.
@@ -81,13 +81,13 @@ The following markup is an example.
8181

8282
1. Validate the modified add-in only manifest. See [Validate an Office Add-in's manifest](../testing/troubleshoot-manifest.md).
8383

84-
1. Verify that the add-in can be sideloaded and run. See [Sideload an Office Add-in for testing](../testing/test-debug-office-add-ins.md#sideload-an-office-add-in-for-testing).
84+
1. Verify that the add-in can be sideloaded and run. See [Sideload an Office Add-in for testing](../testing/test-debug-office-add-ins.md#sideload-an-office-add-in-for-testing).
8585

8686
Resolve any problems before you attempt to convert the project.
8787

8888
## Conversion tools and options
8989

90-
There are several ways to carry out the remaining tasks, depending on the IDE and other tools you want to use for your project, and on the tool you used to create the project.
90+
There are several ways to carry out the remaining tasks, depending on the IDE and other tools you want to use for your project, and on the tool you used to create the project.
9191

9292
- [Convert the project with Teams Toolkit](#convert-the-project-with-teams-toolkit)
9393
- [Convert projects created with the Yeoman generator for Office Add-ins (aka "Yo Office")](#convert-projects-created-with-the-yeoman-generator-for-office-add-ins-aka-yo-office)
@@ -115,7 +115,7 @@ The easiest way to convert is to use Teams Toolkit.
115115

116116
1. The **App Features Using an Office Add-in** dropdown menu opens. The options listed will vary depending on your version of Teams Toolkit. Select **Import an Existing Office Add-in**.
117117

118-
:::image type="content" source="../images/teams-toolkit-create-office-task-pane-capability.png" alt-text="The options in the App Features Using an Office Add-in dropdown menu. One option is called 'Import an Existing Office Add-in'.":::
118+
:::image type="content" source="../images/teams-toolkit-create-office-import-capability.png" alt-text="The options in the App Features Using an Office Add-in dropdown menu. The 'Import an Existing Office Add-in' option is selected.":::
119119

120120
1. In the **Existing add-in project folder** dropdown menu, browse to the root folder of the add-in project.
121121
1. In the **Select import project manifest file** dropdown menu, browse to the add-in only manifest file, typically named **manifest.xml**.
@@ -129,7 +129,7 @@ You can sideload the add-in using the Teams Toolkit or in a command prompt, bash
129129
- [Sideload with Teams toolkit](../testing/sideload-add-in-with-unified-manifest.md#sideload-with-the-teams-toolkit)
130130
- [Sideload with a system prompt, bash shell, or terminal](../testing/sideload-add-in-with-unified-manifest.md#sideload-with-a-system-prompt-bash-shell-or-terminal)
131131

132-
> [!NOTE]
132+
> [!NOTE]
133133
> Add-ins that use the unified manifest can be sideloaded only on Office Version 2304 (Build 16320.20000) or later.
134134
135135
### Convert projects created with the Yeoman generator for Office Add-ins (aka "Yo Office")
115 KB
Loading

docs/outlook/item-multi-select.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Activate your Outlook add-in on multiple messages
33
description: Learn how to activate your Outlook add-in when multiple messages are selected.
4-
ms.date: 03/11/2025
4+
ms.date: 03/19/2025
55
ms.topic: how-to
66
ms.localizationpriority: medium
77
---
@@ -257,7 +257,7 @@ The following example implements the `getSelectedItemsAsync` and `loadItemByIdAs
257257
// Clear the list of previously selected messages, if any.
258258
clearList(list);
259259

260-
// Get the subject line and sender's email address of each selected message and log it to a list in the task pane.
260+
// Get the subject line and sender's email address of each selected message and log them to a list in the task pane.
261261
Office.context.mailbox.getSelectedItemsAsync((asyncResult) => {
262262
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
263263
console.log(asyncResult.error.message);
@@ -273,7 +273,7 @@ The following example implements the `getSelectedItemsAsync` and `loadItemByIdAs
273273
async function getItemInfo(selectedItems) {
274274
for (const item of selectedItems) {
275275
addToList(item.subject);
276-
if (Office.context.diagnostics.platform === Office.PlatformType.PC) {
276+
if (Office.context.requirements.isSetSupported("Mailbox", "1.15")) {
277277
await getSenderEmailAddress(item);
278278
}
279279
}

docs/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,9 @@ items:
962962
- name: Read and write data to the active selection
963963
href: develop/read-and-write-data-to-the-active-selection-in-a-document-or-spreadsheet.md
964964
displayName: Word
965+
- name: Use fields
966+
href: word/fields-guidance.md
967+
displayName: Word
965968
- name: Use search options to find text
966969
href: word/search-option-guidance.md
967970
displayName: Word

docs/word/fields-guidance.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
---
2+
title: Use fields in your Word add-in
3+
description: Learn to use fields in your Word add-in.
4+
ms.date: 03/18/2025
5+
ms.localizationpriority: medium
6+
---
7+
8+
# Use fields in your Word add-in
9+
10+
A [field](https://support.microsoft.com/office/c429bbb0-8669-48a7-bd24-bab6ba6b06bb) in a Word document is a placeholder. It allows you to provide instructions for the content instead of the content itself. You can use fields to create and format a Word template. Word documents support a number of [field types](https://support.microsoft.com/office/1ad6d91a-55a7-4a8d-b535-cf7888659a51), many with associated parameters for configuring the field. However, Word on the web generally doesn't support adding or editing fields through the UI. For more information, see [Field codes in Word for the web](https://support.microsoft.com/office/d8f46094-13c3-4966-98c3-259748f3caf1).
11+
12+
Starting from the WordApi 1.5 requirement set, Word JavaScript APIs allow you to manage fields in your Word add-in. In all platforms, you can get existing fields. You can insert, update, and delete fields in platforms that support those capabilities.
13+
14+
The following sections discuss several of the most frequently used field types: Addin, Date, Hyperlink, and TOC (Table of Contents).
15+
16+
## Addin field
17+
18+
The Addin field is meant to store add-in data that's hidden from the Word user interface, regardless of whether fields in the document are set to show or hide its content. The Addin field isn't available in the Word UI's **Field** dialog box. Use the API to insert the Addin field type and set the field's data.
19+
20+
The following code sample shows how to insert an Addin field before the cursor location or your selection in the Word document.
21+
22+
```javascript
23+
// Inserts an Addin field before selection.
24+
async function rangeInsertAddinField() {
25+
await Word.run(async (context) => {
26+
let range = context.document.getSelection().getRange();
27+
const field = range.insertField(Word.InsertLocation.before, Word.FieldType.addin);
28+
field.load("result,code");
29+
await context.sync();
30+
31+
if (field.isNullObject) {
32+
console.log("There are no fields in this document.");
33+
} else {
34+
console.log("Code of the field: " + field.code);
35+
console.log("Result of the field: " + JSON.stringify(field.result));
36+
}
37+
});
38+
}
39+
```
40+
41+
The following code sample shows how to get the first Addin field found in a document then set that field's data property.
42+
43+
```javascript
44+
// Gets the first Addin field in the document and sets its data.
45+
async function getFirstAddinFieldAndSetData() {
46+
await Word.run(async (context) => {
47+
let myFieldTypes = new Array();
48+
myFieldTypes[0] = Word.FieldType.addin;
49+
const addinFields = context.document.body.fields.getByTypes(myFieldTypes);
50+
let fields = addinFields.load("items");
51+
await context.sync();
52+
53+
if (fields.items.length === 0) {
54+
console.log("No Addin fields in this document.");
55+
} else {
56+
fields.load();
57+
await context.sync();
58+
59+
const firstAddinField = fields.items[0];
60+
firstAddinField.load("code,result,data");
61+
await context.sync();
62+
63+
console.log("The data of the Addin field before being set:", firstAddinField.data);
64+
const data = "Insert your data here";
65+
//const data = $("#input-reference").val(); // Or get user data from your add-in's UI.
66+
firstAddinField.data = data;
67+
firstAddinField.load("data");
68+
await context.sync();
69+
70+
console.log("The data of the Addin field after being set:", firstAddinField.data);
71+
}
72+
});
73+
}
74+
```
75+
76+
## Date field
77+
78+
The Date field inserts the current date according to the format you specify. You can toggle between displaying the date or the field code by setting the `showCodes` field property to `false` or `true` respectively.
79+
80+
The following code sample shows how to insert a Date field before the cursor location or your selection in the Word document.
81+
82+
```javascript
83+
// Inserts a Date field before selection.
84+
async function rangeInsertDateField() {
85+
await Word.run(async (context) => {
86+
let range = context.document.getSelection().getRange();
87+
const field = range.insertField(
88+
Word.InsertLocation.before,
89+
Word.FieldType.date,
90+
'\\@ "M/d/yyyy h:mm am/pm"',
91+
true
92+
);
93+
field.load("result,code");
94+
await context.sync();
95+
96+
if (field.isNullObject) {
97+
console.warn("The field wasn't inserted as expected.");
98+
} else {
99+
console.log("Code of the field: " + field.code);
100+
console.log("Result of the field: " + JSON.stringify(field.result));
101+
}
102+
});
103+
}
104+
```
105+
106+
### Further reading
107+
108+
- [Manage Fields code sample](https://github.com/OfficeDev/office-js-snippets/blob/prod/samples/word/50-document/manage-fields.yaml)
109+
- [Field codes: Date field](https://support.microsoft.com/office/d0c7e1f1-a66a-4b02-a3f4-1a1c56891306)
110+
111+
## Hyperlink field
112+
113+
The Hyperlink field inserts the address of either a location in the same document or an external location such as a webpage. When the user selects it, they're navigated to the specified location. You can toggle between displaying the hyperlink address or the field code by setting the `showCodes` field property to `false` or `true` respectively.
114+
115+
The following code sample shows how to insert a Hyperlink field before the cursor location or your selection in the Word document.
116+
117+
```javascript
118+
// Inserts a Hyperlink field before selection.
119+
async function rangeInsertHyperlinkField() {
120+
await Word.run(async (context) => {
121+
let range = context.document.getSelection().getRange();
122+
const field = range.insertField(
123+
Word.InsertLocation.before,
124+
Word.FieldType.hyperlink,
125+
"https://bing.com",
126+
true
127+
);
128+
field.load("result,code");
129+
await context.sync();
130+
131+
if (field.isNullObject) {
132+
console.warn("The field wasn't inserted as expected.");
133+
} else {
134+
console.log("Code of the field: " + field.code);
135+
console.log("Result of the field: " + JSON.stringify(field.result));
136+
}
137+
});
138+
}
139+
```
140+
141+
### Further reading
142+
143+
- [Field codes: Hyperlink field](https://support.microsoft.com/office/864f8577-eb2a-4e55-8c90-40631748ef53)
144+
145+
## TOC (Table of Contents) field
146+
147+
The TOC field inserts a table of contents, which lists certain areas of a document, like headings. You can toggle between displaying the table of contents or the field code by setting the `showCodes` field property to `false` or `true` respectively.
148+
149+
The following code sample shows how to insert a TOC field at the cursor location or replace your current selection in the Word document.
150+
151+
```javascript
152+
/**
153+
1. Run setup.
154+
1. Select "[To place table of contents]" paragraph.
155+
1. Run rangeInsertTOCField.
156+
*/
157+
158+
// Inserts a TOC (table of contents) field replacing selection.
159+
async function rangeInsertTOCField() {
160+
await Word.run(async (context) => {
161+
let range = context.document.getSelection().getRange();
162+
const field = range.insertField(
163+
Word.InsertLocation.replace,
164+
Word.FieldType.toc
165+
);
166+
field.load("result,code");
167+
await context.sync();
168+
169+
if (field.isNullObject) {
170+
console.warn("The field wasn't inserted as expected.");
171+
} else {
172+
console.log("Code of the field: " + field.code);
173+
console.log("Result of the field: " + JSON.stringify(field.result));
174+
}
175+
});
176+
}
177+
178+
// Prep document so there'll be elements that could be included in a table of contents.
179+
async function setup() {
180+
await Word.run(async (context) => {
181+
const body: Word.Body = context.document.body;
182+
body.clear();
183+
body.insertParagraph("Document title", "End").styleBuiltIn = Word.BuiltInStyleName.title;
184+
body.insertParagraph("[To place table of contents]", "End").styleBuiltIn = Word.BuiltInStyleName.normal;
185+
body.insertParagraph("Introduction", "End").styleBuiltIn = Word.BuiltInStyleName.heading1;
186+
body.insertParagraph("Paragraph 1", "End").styleBuiltIn = Word.BuiltInStyleName.normal;
187+
body.insertParagraph("Topic 1", "End").styleBuiltIn = Word.BuiltInStyleName.heading1;
188+
body.insertParagraph("Paragraph 2", "End").styleBuiltIn = Word.BuiltInStyleName.normal;
189+
body.insertParagraph("Topic 2", "End").styleBuiltIn = Word.BuiltInStyleName.heading1;
190+
body.insertParagraph("Paragraph 3", "End").styleBuiltIn = Word.BuiltInStyleName.normal;
191+
});
192+
}
193+
```
194+
195+
### Further reading
196+
197+
- [Field codes: TOC (Table of Contents) field](https://support.microsoft.com/office/1f538bc4-60e6-4854-9f64-67754d78d05c)
198+
199+
## See also
200+
201+
- [Field codes in Word for the web](https://support.microsoft.com/office/d8f46094-13c3-4966-98c3-259748f3caf1)
202+
- [Insert, edit, and view fields in Word](https://support.microsoft.com/office/c429bbb0-8669-48a7-bd24-bab6ba6b06bb)

0 commit comments

Comments
 (0)