You may receive the following error when opening a Word document from SharePoint:
We couldn't register this document. You won't be able to create links from other documents to this one.
Or you may receive the following error when opening an Excel workbook from SharePoint:
The file could not be accessed.
These two errors can happen if the file has a long file path.
Per the following document, Office (Word/PowerPoint) has a 260 character limitation in the full file path, which includes the path and the file name, when used with SharePoint:
There is a different limitation in Excel for the file path, which is 218 characters:
These limits apply to both SharePoint on-premise and SharePoint Online as the limitation is in Office.
To fix the error, reduce length of the file name so that the full file path is below the character limit.