To prevent Excel from updating local/relative links to SharePoint when saving OneDrive-synced-to-SharePoint files locally:
Excel Options > Trust Center > Trust Center Settings > External Content > "Prompt user on automatic update for Workbook Links" or "Disable automatic update of Workbook Links"
It worked for me, links to files in the same folder keeps pointing to my C:\ drive, even if the folder is synced with OneDrive to a SharePoint site. I have also tested that when files A and B are open, with A linked to B, if I save B with another name, let's say B2, link is correctly updated in A.
If somehow you got a link updated because you had the "Enable automatic update for all Workbook Links (not recommended)" option selected, and if Excel is too long to update the link with the Data > Edit Links tool, you can still manually update it like this while the file is not open:
- unzip your Excel file, you should get a folder with the same name
- find the relation file for the link:
\xl\externalLinks\_rels\externalLink1.xml.rels
- change the relative link to a url encoded path after the
Target
parameter without changing anything else (with notepad.exe for example) :
<Relationship TargetMode="External" Target="file:///C:\Users\AAA\fichier%20étude.xlsx" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath" Id="rId1"/>
(only the space character seemed to be encoded in my case)
- re-zip the content of the folder (and NOT the folder itself, this is very important!)
- rename the zip file to something different from your original file name (typically add something at the end") and change the .zip extension to the same extension that your original file (.xlsx or *.xlsm generally)