I am struggling to enhance the functionality of a word add-in by implementing new features. If anyone can provide assistance, it would be greatly appreciated :)
The current challenge I am facing is related to a button in the add-in. When this button is clicked, I want the first occurrence of a specific string to be selected within the text of the Word document.
Any help or guidance on this matter would be highly valued! Thank you in advance!
package.json "@types/office-js": "0.0.75",
Edit:
HTML Code
<a href="#" class="button-select-text (click)="selectText(givenString)">
Angular Code
public selectText(givenString: string) {
console.log('String to select: ' + givenString);
if (this._common.officeVersion[0] !== '16') {
this._common.getWordFile('', Office.FileType.Text)
.then(response => {
console.log('Text from Word: ' + response.fileContent);
// todo now select/mark the givenString in word itself
});
} else {
Word.run(context => {
const wordText = context.load(context.document.body, 'text');
console.log('Text from Word: ' + wordText);
// todo now select/mark the givenString in word itself
});
}
}