2017-08-17 3 views
0

Ich möchte die Inhaltskontrolle in Word mit Office-js Wort api hinzufügen. Ich verwende die insertContentControl-Methode, aber diese Methode wird nicht am Ende des Dokuments oder am bestimmten Einfügeort hinzugefügt. Unten ist mein Code: -Einfügen der Inhaltskontrolle in Word mit Office-js Wort api

Word.run(function (context) { 


      var body = context.document.body; 
      var contents = body.contentControls; 
      // Queue a commmand to wrap the body in a content control. 
      var a = body.insertContentControl(); 
      a.appearance = "name"; 
      a.tag = "name1"; 
      a.title = "name"; 


      return context.sync().then(function() { 
       // context.load(body); 
       console.log('Wrapped the body in a content control.'); 
      }); 
     }) 
     .catch(function (error) { 

      console.log('Error: ' + JSON.stringify(error)); 
      if (error instanceof OfficeExtension.Error) { 
       console.log('Debug info: ' + JSON.stringify(error.debugInfo)); 
      } 
     }); 

Auch mag ich die Eigenschaften, um es wie Aussehen, Tag, Titel auf das neue Content-Steuerelement hinzuzufügen erstellt

Antwort

0

Gemäß der Dokumentation von insertContentControl() wird es wickeln der gesamte Körper als Inhaltskontrolle, wird es nicht eine neue Inhaltskontrolle schließlich hinzufügen. dies ist aus der Dokumentation

https://dev.office.com/reference/add-ins/word/body

Wenn Sie einen neuen Inhaltskontrolle in Ihrem Add-In hinzufügen möchten Sie apis mit OOXML, dass es möglich ist, einen neuen Inhaltskontrolle einzusetzen.

Verwandte Themen