Dear Sandhya Sriram
Thank you for reaching out to the Microsoft Q&A forum.
According to Microsoft’s official documentation, the presentation.id property is simply described as “Gets the ID of the presentation.” However, there is no indication that this value is a GUID or a globally unique identifier.
From what I’ve researched, the common method to assign a unique identifier to a PowerPoint file is to use custom tags. This approach allows you to embed a key-value pair (e.g., "MY_ID": "") into the file’s metadata. This value is stored within the file itself and persists across sessions, saves, and even when the file is copied or moved. Any device or session that opens the file (with your add-in) can read the tag you assigned.
If you are using PowerPoint API 1.7 or later, you can use presentation.properties.customProperties.add(key, value) to create or update a custom property. This method stores the data in the same metadata area as tags and is consistent with the Word/Excel object model. However, this API is only available in newer versions of Office (Windows, Mac, Web). If your add-in needs to support older Office versions, consider using tags instead.
Another option is to use the file path or URL as an identifier. If the file has been saved, you can retrieve its path or URL using Office.context.document.url or getFilePropertiesAsync. However, this is not a stable identifier since users can rename or move the file, which changes the path. For local files, the path is only unique on a specific machine. This method is suitable for identifying files during the current session, but it does not guarantee long-term uniqueness across sessions or devices. Also, for unsaved files, there is no path to retrieve.
If your file is stored on OneDrive or SharePoint, each document has a globally unique DriveItem ID. You can retrieve this ID using Microsoft Graph API. This ID is system-generated, globally unique, and remains stable even if the file is renamed or moved within the same folder. However, Office.js does not expose this ID directly, you must implement Graph API calls, which require user authentication and permissions. This method is best suited for cloud-based workflows or when integrating with external systems.
For local-only scenarios, using tags remains the most practical approach.
Reference sources:
- PowerPoint.Presentation class
- What's new in PowerPoint JavaScript API 1.7
- Use custom tags for presentations, slides, and shapes in PowerPoint
- Custom properties support in powerpoint
I hope this information is helpful.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.