d'abord, créer un menu déroulant en HTML
<div>
<select class="form-control" (change)="yesClicked($event.target.value)">
<option value="choose" >choose option</option>
<option value="Yes">Yes</option>
<option value="No" >No</option>
</select>
puis ajouter un code de script de type
yesClicked(eventName:any){
if(eventName=='Yes')
{
this.wordDocument.yesclicked();
}
else if(eventName =='No')
{
this.wordDocument.Noclicked();
}
}
alors définir la fonction
yesclicked()
{
Word.run(function (context) {
var body = context.document.body;
body.insertParagraph('Content of a new paragraph',
Word.InsertLocation.end);
return context.sync().then(function() {
console.log('Paragraph added at the end of the document body.');
});
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
}
Je vous suggère d'essayer vous-même avant de demander une soluti sur. –
Je l'ai essayé. La partie HTML est
Modifier la question afin qu'il comprenne le code à la place –