Save file in folder

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,064
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have this code and its creates a folder and saves a workbook

Not clear as what is wrong with the code. it is giving error as Error 1004

VBA Code:
Sub FoldtoBackupA()
Dim Path As String
Dim path1 As String
Dim Folder As String
Dim Answer As VbMsgBoxResult
Dim relativePath As String
    Path = Application.ThisWorkbook.Path & "\" & "ISFReportAtt"
    Folder = Dir(Path, vbDirectory)
    If Folder = vbNullString Then
                 VBA.FileSystem.MkDir (Path)
    'Exit Sub
    Else
        'MsgBox "Folder exists."
    End If
Call SaveFile1
End Sub

Sub SaveFile1()
Dim sFilename As String

'Refersh Pivot Table
Workbooks("Fiserv Intraday Generator Hourly.xlsb").Activate
sFilename = Sheets("Email").Range("c5").Value & ".xlsx"

Workbooks.Add
'Saving the Workbook
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFReportAtt" & "\" & sFilename  [B]' Error 1004[/B]

End sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Check the variable of the codeline where the error occurs …​
 
Upvote 0
Something invalid in the path or some invalid character, check it all …​
 
Upvote 0

Forum statistics

Threads
1,216,818
Messages
6,132,877
Members
449,765
Latest member
Coffebreak

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top