Hello,
I am trying to save my file in a network path with a filename provided in a cell. However, I am getting a run-time error '1004': Method 'Save As' of object '_Workbook' failed error.
When I debug is see the code highlighted at this point of the code:
Below is the full code:
What did I miss?
Thank you,
I am trying to save my file in a network path with a filename provided in a cell. However, I am getting a run-time error '1004': Method 'Save As' of object '_Workbook' failed error.
When I debug is see the code highlighted at this point of the code:
VBA Code:
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
Below is the full code:
VBA Code:
Sub Create_Final_Version()
'Create the final version
Dim FileExtStr As String
Dim wbname As String
Dim FileFormatNum As Long
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim sh As Worksheet
Dim year As Integer
app_functions_ON
FileExtStr = ".xlsm": FileFormatNum = 52
Set Destwb = ActiveWorkbook
'wbname = Left(Destwb.Name, 25)
Set sh = Sheets("Control")
wbname = sh.Range("C16")
year = sh.Range("B5")
TempFilePath = "\\namicgdfs\cpna_data_grp\IT RMO PBI\Audit and Control\" & year & " Audit Metrics\" & year & " Audit Plan\Audit Plan - Previous - FINAL\"
TempFileName = wbname
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
'.Close savechanges:=False
End With
'MsgBox "You can find the new file in " & TempFilePath
app_functions_OFF
End Sub
What did I miss?
Thank you,