MrPink1986
Active Member
- Joined
- May 1, 2012
- Messages
- 252
Hi there,
I have created a macro which saves a sheet from a workbook in a location that that changes daily. This is captured in the macro by using formulas in excel. The macro seems to create the file as expected however I get to the following line and it fails to save
- I get a runtime error 1004.
The CheminDest string created seems to be fine and I cant seem to figure it out.
My code is below
Any help greatly appreciated.
I have created a macro which saves a sheet from a workbook in a location that that changes daily. This is captured in the macro by using formulas in excel. The macro seems to create the file as expected however I get to the following line and it fails to save
Code:
.SaveAs Filename:=CheminDest & fNAME & ".xlsx"
The CheminDest string created seems to be fine and I cant seem to figure it out.
My code is below
Code:
Sub Save_Upload()
Dim WS As Worksheet, CheminDest As String, fNAME As String
On Error Resume Next
CheminDest = "C:\Data\4XXX\" & Sheets("Manual Price Assets").Range("R11") & "\" & Sheets("Manual Price Assets").Range("R13") & "\" & Sheets("Manual Price Assets").Range("R14") & "\"
MkDir CheminDest
On Error GoTo 0
fNAME = Sheets("Manual Price Assets").Range("R20")
Sheets(Array("Upload File")).Copy
Sheets("Upload File").Name = "Upload File"
With ActiveWorkbook
For Each WS In .Worksheets
Next WS
.SaveAs Filename:=CheminDest & fNAME & ".xlsx"
.Close Fasle
End With
MsgBox "Text file has been saved ", vbInformation, "Data backup"
End Sub
Any help greatly appreciated.
Last edited: