Edgarvelez
Board Regular
- Joined
- Jun 6, 2019
- Messages
- 197
- Office Version
- 2016
- Platform
- Windows
Hi all,
I have a code sown below which works and has for years.
We now have Microsoft OneDrive and it doesn't work and I get an error, if I turn off OneDrive it works great.
All the code does it takes one of the sheets copies it, saves & renames it to the same folder the macro is regardless of the folder location.
Full Code below
I have a code sown below which works and has for years.
We now have Microsoft OneDrive and it doesn't work and I get an error, if I turn off OneDrive it works great.
All the code does it takes one of the sheets copies it, saves & renames it to the same folder the macro is regardless of the folder location.
Full Code below
VBA Code:
Sheets("DATA PAGE").Select
Range("A1").Select
Dim fname As String
Dim fpath As String
Dim name As String
Dim ws As Worksheet
If ActiveWorkbook.AutoSaveOn Then ActiveWorkbook.AutoSaveOn = False
fpath = ActiveWorkbook.Path
'ActiveWorkbook.Path
fname = Range("D7") & " " & Range("D8") & " PSO " & Range("'HYD PACKING LIST'!I6") & "-1 " & Range("D10") & ".xlsx"
name = Range("D7").Value
On Error Resume Next
Set ws = ThisWorkbook.Sheets("UPLOAD SHEET")
On Error GoTo 0
If ws Is Nothing Then
MsgBox "sheet doesn't exist"
Exit Sub
End If
If Dir(fpath & "\" & fname) = vbNullString Then
ThisWorkbook.Sheets("UPLOAD SHEET").Copy
ActiveWorkbook.SaveAs Filename:=fpath & "\" & fname
Else
msg = MsgBox(fname & Chr(10) & Chr(10) & "This File Name Already Exists In The Folder!!" & Chr(10) & Chr(10) & _
"Click YES to continue to save and overwrite the file" & Chr(10) & _
"Or NO to to cancel the Save", vbYesNo, "STOP!")
If msg = vbYes Then
Application.DisplayAlerts = False
ThisWorkbook.Sheets("UPLOAD SHEET").Copy
ActiveWorkbook.SaveAs Filename:=fpath & "\" & fname
Application.DisplayAlerts = True
Else
MsgBox "File save cancelled"
End If
End If
End Sub