Accessing Microsoft Formats like .pptx and .docx in SharePoint Online and OneDrive
In today's modern workplace, collaboration and file sharing have become an essential part of daily operations. Microsoft's OneDrive and SharePoint Online are two popular cloud storage and collaboration platforms that enable users to access, share, and collaborate on files from anywhere, at any time. This article focuses on how to access Microsoft formats like .pptx and .docx in SharePoint Online and OneDrive.
What are SharePoint Online and OneDrive?
SharePoint Online and OneDrive are two cloud-based storage and collaboration platforms offered by Microsoft as part of its Office 365 suite. SharePoint Online is a web-based collaborative platform that integrates with Microsoft Office. It is primarily used for document management and storage, intranet portals, content management, and business intelligence. OneDrive, on the other hand, is a personal cloud storage service that allows users to store, share, and sync files across multiple devices.
Accessing Microsoft Formats in SharePoint Online
Accessing Microsoft formats like .pptx and .docx in SharePoint Online is straightforward. You can access these files directly from the SharePoint Online interface by navigating to the document library where the files are stored. Once you locate the file, you can click on it to open and edit it using the appropriate Microsoft Office application.
// Accessing .pptx file in SharePoint Online
var siteUrl = "https://.sharepoint.com/sites/";
var context = new SP.ClientContext(siteUrl);
var web = context.get_web();
var list = web.get_lists().getByTitle("");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("" + fileName + " ");
var files = list.getItems(camlQuery);
context.load(files);
context.executeQueryAsync(function () {
var file = files.itemAt(0).get_file();
context.load(file);
context.executeQueryAsync(function () {
// Open the file in PowerPoint Online
var pptFileUrl = file.get_serverRelativeUrl();
var iframe = document.createElement("iframe");
iframe.src = pptFileUrl + "/PowerPointFrame.aspx";
iframe.width = "100%";
iframe.height = "600px";
document.body.appendChild(iframe);
}, function (sender, args) {
console.log("Error: " + args.get_message());
});
}, function (sender, args) {
console.log("Error: " + args.get_message());
});
Accessing Microsoft Formats in OneDrive
Accessing Microsoft formats like .pptx and .docx in OneDrive is also straightforward. You can access these files directly from the OneDrive interface by navigating to the folder where the files are stored. Once you locate the file, you can click on it to open and edit it using the appropriate Microsoft Office application.
// Accessing .docx file in OneDrive
function openDocxFile(fileId) {
var iframe = document.createElement("iframe");
iframe.src = "https://-my.sharepoint.com/personal//_layouts/15/Doc.aspx?sourcedoc=" + fileId + "&action=default&uid=&z=1";
iframe.width = "100%";
iframe.height = "600px";
document.body.appendChild(iframe);
}
- SharePoint Online and OneDrive are two cloud-based storage and collaboration platforms offered by Microsoft as part of its Office 365 suite.
- Accessing Microsoft formats like .pptx and .docx in SharePoint Online and OneDrive is straightforward.
- You can access these files directly from the SharePoint Online or OneDrive interface by navigating to the document library or folder where the files are stored.
- Once you locate the file, you can click on it to open and edit it using the appropriate Microsoft Office application.
- Microsoft SharePoint Online: https://docs.microsoft.com/en-us/sharepoint/overview-of-sharepoint-online
- Microsoft OneDrive: https://www.microsoft.com/en-us/microsoft-365/onedrive/online-cloud-storage
- Accessing SharePoint Files with REST: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-rest-services-in-sharepoint
- Opening OneDrive Files with JavaScript: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/open-onedrive-files-using-javascript
References
Note: The above code blocks are written in JavaScript and are meant to be used as examples only. They may not work as-is in a production environment.