OfficeDev / office-js-docs-pr

Microsoft Office Add-ins Documentation
https://learn.microsoft.com/office/dev/add-ins
Creative Commons Attribution 4.0 International
391 stars 241 forks source link

Unable to read hyperlink in Powerpoint and Excel #4342

Closed adithyasai closed 5 months ago

adithyasai commented 6 months ago

Article URL

We are trying to read the hyperlink from

Issue

We are facing the following issues with OfficeJS and i dont see that mentioned anywhere in the documentation

Can you please point me the right place if thats already documented somewhere https://learn.microsoft.com/en-us/javascript/api/excel/excel.range?view=excel-js-preview#excel-excel-range-hyperlink-member

davidchesnut commented 6 months ago

Hi @adithyasai,

You can get the hyperlink for a range in Excel by using the following code:

async function run() {
  await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getActiveWorksheet();

    const range = sheet.getRange("A1");
    await context.sync();
    range.load("hyperlink");
    await context.sync();
    console.log(range.hyperlink);

  });
}

I don't believe PowerPoint has a way to get the hyperlink for various objects. You could submit a feature request for this with more details about your scenario here: https://aka.ms/m365dev-suggestions.

Cheers, David

Rick-Kirkham commented 6 months ago

[like] Ricky Kirkham reacted to your message:


From: David Chesnut @.> Sent: Friday, January 5, 2024 8:28:21 PM To: OfficeDev/office-js-docs-pr @.> Cc: Subscribed @.***> Subject: Re: [OfficeDev/office-js-docs-pr] Unable to read hyperlink in Powerpoint and Excel (Issue #4342)

Hi @adithyasaihttps://github.com/adithyasai,

You can get the hyperlink for a range in Excel by using the following code:

async function run() { await Excel.run(async (context) => { const sheet = context.workbook.worksheets.getActiveWorksheet();

const range = sheet.getRange("A1");
await context.sync();
range.load("hyperlink");
await context.sync();
console.log(range.hyperlink);

}); }

I don't believe PowerPoint has a way to get the hyperlink for various objects. You could submit a feature request for this with more details about your scenario here: https://aka.ms/m365dev-suggestions.

As a workaround, you may potentially be able to find PowerPoint hyperlinks by examining the Open XML file of the presentation. For more information see the following resources. Many are for Word but the techniques should also apply to PowerPoint.

Cheers, David

— Reply to this email directly, view it on GitHubhttps://github.com/OfficeDev/office-js-docs-pr/issues/4342#issuecomment-1879221416 or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACFKYOCPA2CL3GDDL4HNLNDYNBO6NBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIYTINRZGM3DAMZVG2SG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJRGA4TOMRTGM3DFAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDEMBWGY4DINJUGA4IFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIYTINRZGM3DAMZVG2TXI4TJM5TWK4VGMNZGKYLUMU. You are receiving this email because you are subscribed to this thread.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

davidchesnut commented 5 months ago

I updated my previous comment to remove the information on getting and setting OOXML. PowerPoint does not support the OOXML coercion type. For more information on supported coercion types, see the tables in getSelectedDataAsync.