I have a code as below. It is copying the sheet and save it as new workbook in same folder with the active workbook.dialog box open and user type a new name for this new workbook. however it is not working anymore since company moved the folders into onedrive.
NewName = InputBox("Please Specify the name of your new workbook", "New Copy")
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & ".xlsx"
ActiveWorkbook.Close SaveChanges:=False
I have fullname function to also change file format as pdf and it is working.
sPath = ActiveWorkbook.FullName
FileName = LocalFullName(ActiveWorkbook.FullName)
ActiveWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=Left(FileName, InStr(FileName, ".") - 1), _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Private Function LocalFullName$(ByVal fullPath$)
Dim ii&
Dim iPos&
Dim oneDrivePath$
Dim endFilePath$
If Left(fullPath, 8) = "https://" Then
If InStr(1, fullPath, "my.sharepoint.com") <> 0 Then
iPos = InStr(1, fullPath, "/Documents") + Len("/Documents")
endFilePath = Mid(fullPath, iPos)
Else
iPos = 8
For ii = 1 To 2
iPos = InStr(iPos + 1, fullPath, "/")
Next ii
endFilePath = Mid(fullPath, iPos)
End If
endFilePath = Replace(endFilePath, "/", Application.PathSeparator)
For ii = 1 To 3
oneDrivePath = Environ(Choose(ii, "OneDriveCommercial", "OneDriveConsumer", "OneDrive"))
If 0 < Len(oneDrivePath) Then
LocalFullName = oneDrivePath & endFilePath
Exit Function
End If
Next ii
LocalFullName = vbNullString
Else
LocalFullName = fullPath
End If
End Function
I cannot apply fullname inside not working code.