I have code that saves file copy with .xlsx extension, then opens it and deletes old one. It works perfectly with files that are located only on my computer but if I try to use it with folders that are synced with OneDrive it gives me "File not found" error. It has to be because of that fact that wb.FullName in this case looks like web link to a file on OneDrive and not path+file name on my computer. Any ideas how to avoid this without moving files to another folder and then copying it back manually?
Sub Resave_and_open()
Dim fn As String
Dim fnold As String
Dim l As Long
Dim wb As Workbook
Set wb = ActiveWorkbook
fnold = wb.FullName
l = InStrRev(fnold, ".")
fn = Left(fnold, l)
fn = fn & "xlsx"
wb.SaveAs Filename:=fn, FileFormat:=xlOpenXMLWorkbook
wb.Close
Workbooks.Open Filename:=fn
Kill fnold
End Sub
With files on my computer only it looks like this and works fine