Compartilhar via


Word.ContentControlType enum

Especifica subtipos e tipos de controlo de conteúdo suportados.

Comentários

[ Conjunto de API: WordApi 1.1 ]

Exemplos

// 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();
});

Campos

buildingBlockGallery = "BuildingBlockGallery"
checkBox = "CheckBox"
comboBox = "ComboBox"
datePicker = "DatePicker"
dropDownList = "DropDownList"
picture = "Picture"
plainText = "PlainText"
plainTextInline = "PlainTextInline"
plainTextParagraph = "PlainTextParagraph"
repeatingSection = "RepeatingSection"
richText = "RichText"

Identifica um controlo de conteúdo de texto formatado.

richTextInline = "RichTextInline"
richTextParagraphs = "RichTextParagraphs"
richTextTable = "RichTextTable"

Contém uma tabela inteira.

richTextTableCell = "RichTextTableCell"

Contém uma célula inteira.

richTextTableRow = "RichTextTableRow"

Contém uma linha inteira.

unknown = "Unknown"