J'ai créé un addin taskpane pour un mot qui lance une recherche et affichera le texte du premier paragraphe pour le résultat de la recherche. Jusqu'à il y a quelques jours, le code suivant est en cours d'exécution avec succès:Comment paragraphCollection.first doit-il être utilisé dans le mot javascript api
function onGetFirstRangeParaClick() {
var textToFind = "Word",
range,
paragraph;
return Word.run(function (context) {
var searchResults = context.document.body.search(textToFind, { matchWildCards: false });
context.load(searchResults, "text");
return context.sync()
.then(function() {
range = searchResults.items[0].getRange();
context.load(range, "text, paragraphs");
return context.sync();
})
.then(function() {
paragraph = range.paragraphs.first;
context.load(paragraph, "text");
return context.sync();
})
.then(function() {
$("#getFirstRangeParaResult").text(paragraph.text);
});
})
.catch(onError);
}
Mais maintenant, l'erreur suivante est générée:
{"name":"OfficeExtension.Error","code":"GeneralException","message":"GeneralException","traceMessages":[],"debugInfo":{"errorLocation":"ParagraphCollection.first"},"stack":"GeneralException: GeneralException\\n at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:8360:6)\\n at lib$es6$promise$$internal$$tryCatch (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9595:8)\\n at lib$es6$promise$$internal$$invokeCallback (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9605:8)\\n at lib$es6$promise$$internal$$publish (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9581:9)\\n at lib$es6$promise$asap$$flush (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9400:8)"}
J'utilise le débogage PreviewCDN (//appsforoffice.microsoft. com/lib/bêta/hébergés/office.debug.js) et je suis en cours d'exécution version bureau 1610 (Build 7466,2038)
J'ai remarqué dans les documents qui paragraphs.first
api est en train de changer à paragraphs.getFirst()
mais ne regarde pas ce genre est encore mis en œuvre comme si je change d'utiliser getFirst()
je reçois l'erreur suivante:
Object doesn't support property or method 'getFirst'
Comment dois-je utiliser d'abord ou getFirst() pour une ParagraphCollection?
pour donner suite à cette BETA cdn a été mis à jour et nous avons maintenant les saveurs de la méthode :) –