Word.ContentControlType enum
Spécifie les types et sous-types de contrôle de contenu pris en charge.
Remarques
[ Ensemble d’API : WordApi 1.1 ]
Exemples
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the content controls collection.
const contentControls = context.document.contentControls;
// Queue a command to load the id property for all of the content controls.
contentControls.load('id');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
if (contentControls.items.length === 0) {
console.log('No content control found.');
}
else {
// Queue a command to load the properties on the first content control.
contentControls.items[0].load( 'appearance,' +
'cannotDelete,' +
'cannotEdit,' +
'color,' +
'id,' +
'placeHolderText,' +
'removeWhenEdited,' +
'title,' +
'text,' +
'type,' +
'style,' +
'tag,' +
'font/size,' +
'font/name,' +
'font/color');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Property values of the first content control:' +
' ----- appearance: ' + contentControls.items[0].appearance +
' ----- cannotDelete: ' + contentControls.items[0].cannotDelete +
' ----- cannotEdit: ' + contentControls.items[0].cannotEdit +
' ----- color: ' + contentControls.items[0].color +
' ----- id: ' + contentControls.items[0].id +
' ----- placeHolderText: ' + contentControls.items[0].placeholderText +
' ----- removeWhenEdited: ' + contentControls.items[0].removeWhenEdited +
' ----- title: ' + contentControls.items[0].title +
' ----- text: ' + contentControls.items[0].text +
' ----- type: ' + contentControls.items[0].type +
' ----- style: ' + contentControls.items[0].style +
' ----- tag: ' + contentControls.items[0].tag +
' ----- font size: ' + contentControls.items[0].font.size +
' ----- font name: ' + contentControls.items[0].font.name +
' ----- font color: ' + contentControls.items[0].font.color);
}
});
// 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
// Traverses each paragraph of the document and places a checkbox content control at the beginning of each.
await Word.run(async (context) => {
let paragraphs = context.document.body.paragraphs;
paragraphs.load("$none"); // Don't need any properties; just start each paragraph with a content control.
await context.sync();
for (let i = 0; i < paragraphs.items.length; i++) {
let contentControl = paragraphs.items[i]
.getRange(Word.RangeLocation.start)
.insertContentControl(Word.ContentControlType.checkBox);
}
console.log("Checkbox content controls inserted: " + paragraphs.items.length);
await context.sync();
});
Champs
buildingBlockGallery = "BuildingBlockGallery" | |
checkBox = "CheckBox" | |
comboBox = "ComboBox" | |
datePicker = "DatePicker" | |
dropDownList = "DropDownList" | |
picture = "Picture" | |
plainText = "PlainText" | |
plainTextInline = "PlainTextInline" | |
plainTextParagraph = "PlainTextParagraph" | |
repeatingSection = "RepeatingSection" | |
richText = "RichText" | Identifie un contrôle de contenu de texte enrichi. |
richTextInline = "RichTextInline" | |
richTextParagraphs = "RichTextParagraphs" | |
richTextTable = "RichTextTable" | Contient une table entière. |
richTextTableCell = "RichTextTableCell" | Contient une cellule entière. |
richTextTableRow = "RichTextTableRow" | Contient une ligne entière. |
unknown = "Unknown" |
Collaborer avec nous sur GitHub
La source de ce contenu se trouve sur GitHub, où vous pouvez également créer et examiner les problèmes et les demandes de tirage. Pour plus d’informations, consultez notre guide du contributeur.