I am re wording this question to be more specific:

Using the site, path, and file name how do you build a link to a document, programmatically or using an excel formula.

In previous versions you simply built a link like the example below and its would allow a user to link to that document.

Site = constant (https://site.sharepoint.com/sites/TestSite)

Path = variable (Document Library/subfolder/subfolder)

file = variable (filename.*)

eg. https://site.sharepoint.com/sites/TestSite/Controlled_Doc/Subfolder/attachments/Photo1.jpg

Been going in circles on the forums and can't find a reference to what the character substitutions should be for sub-folders if that is the source of the problem. This is very similar to the question asked Can I link to a SharePoint document using the site name, folder, and name? how ever this is specific to the modern pages in SharePoint Online. If the problem is just in the formating of the link as specified for sub folders what is the reference for the character substitution?

For context this will be going in a cell within a spreadsheet that is already populated with a large volume of data.

Not interested in the GUI features within SharePoint like export to excel or the option to copy link by pressing a button. I would like to avoid coding if possible and building an API call.

  • Do you want to get the clean URL of documents inside subfolders in document library?? Jul 31 '19 at 7:18
  • basically don't care too much about the link structure so long as it works. going into a spreadsheet for very low tech users. Jul 31 '19 at 7:20
  • So What do you want exactly? Do you want to export the url for all documents in Excel file or just the clean url for some particular document? Jul 31 '19 at 7:24
  • the ability to link to a document in a sharepoint online environment using the path and filename as the input to build the link. Jul 31 '19 at 7:32
  • I don't know your all requirements but you can use Export to Excel option in SharePoint online which will give you the link to the documents easily. Jul 31 '19 at 7:36

The path and filename escaping in SharePoint isn't anything unique. You can make sure your path is handling special characters by passing the text through the ENCODEURL function in Excel. This will automatically replace spaces with %20 for example.

  • This fixes the encoding but the links are still not working Jul 31 '19 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.