1+ id : powerpoint-manage-hyperlinks
2+ name : Get hyperlinks
3+ description : Gets the hyperlinks found in a slide.
4+ host : POWERPOINT
5+ api_set :
6+ PowerPointApi : ' 1.6'
7+ script :
8+ content : |
9+ $("#get-hyperlinks").on("click", () => tryCatch(getHyperlinks));
10+
11+ async function getHyperlinks() {
12+ // Gets the hyperlinks found in the first selected slide.
13+ await PowerPoint.run(async (context) => {
14+ const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
15+ const hyperlinks: PowerPoint.HyperlinkCollection = slide.hyperlinks.load("address,screenTip");
16+ const hyperlinksCount = hyperlinks.getCount();
17+ await context.sync();
18+
19+ console.log(`${hyperlinksCount.value} hyperlinks found in first selected slide:`);
20+ for (let link of hyperlinks.items) {
21+ console.log(`Address: "${link.address}" (Screen tip: "${link.screenTip}")`);
22+ }
23+ });
24+ }
25+
26+ /** Default helper for invoking an action and handling errors. */
27+ async function tryCatch(callback) {
28+ try {
29+ await callback();
30+ } catch (error) {
31+ // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
32+ console.error(error);
33+ }
34+ }
35+ language : typescript
36+ template :
37+ content : |-
38+ <section class="ms-font-m">
39+ <p class="ms-font-m">Demonstrates how to get the hyperlinks located in a slide.</p>
40+ </section>
41+
42+ <section class="samples ms-font-m">
43+ <h3>Try it out</h3>
44+ <p>First, add at least one hyperlink to a slide then select at least one slide.</p>
45+ <button id="get-hyperlinks" class="ms-Button">
46+ <span class="ms-Button-label">Get hyperlinks</span>
47+ </button>
48+ </section>
49+ language : html
50+ style :
51+ content : |-
52+ section.samples {
53+ margin-top: 20px;
54+ }
55+
56+ section.samples .ms-Button, section.setup .ms-Button {
57+ display: block;
58+ margin-bottom: 5px;
59+ margin-left: 20px;
60+ min-width: 80px;
61+ }
62+ language : css
63+ libraries : |
64+ https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
65+ @types/office-js-preview
66+
67+ [email protected] /dist/css/fabric.min.css 68+ [email protected] /dist/css/fabric.components.min.css 69+
70+ [email protected] /client/core.min.js 71+ @types/core-js
72+
73+ 74+
0 commit comments