Save a file

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,134
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have this code it creates a folder and code is trying to save the current file in the created folder

but not sure its not working, can there be a fix.



VBA Code:
Sub FoldtoBackup()

'===================================================
    ' This will creat a backup folder by name Daily Hajj Final Report
'===================================================

Dim Path As String
Dim path1 As String
Dim Folder As String
Dim Answer As VbMsgBoxResult
Dim relativePath As String
    Path = Application.ThisWorkbook.Path & "\" & "Daily Hajj Final Report"
    Folder = Dir(Path, vbDirectory)
    If Folder = vbNullString Then
                 VBA.FileSystem.MkDir (Path)
    'Exit Sub
    Else
        'MsgBox "Folder exists."
    End If
 
 
Sheets(Array("Summary", "Sheet1", "Fiber RawData", _
        "Copper RawData", "FTTM 1 RawData", "FTTM 2 RawData", "FTTH RawData", "Fiber Mak Mad Haram")).Select
    Sheets("Summary").Activate
    Sheets(Array("Summary", "Sheet1", "Fiber RawData", _
        "Copper RawData", "FTTM 1 RawData", "FTTM 2 RawData", "FTTH RawData", "Fiber Mak Mad Haram")).Copy
    ChDir Path           '"D:\"
    
    On Error Resume Next
    'Kill "D:\Print Raw Data.xlsx"
    ActiveWorkbook.SaveAs Filename:= _
        Path & "\" & Sheets("Report").Range("d5").Value.xlsx, FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close  ''' Here is the problem
    Sheets("Report").Select
    Range("E7").Select
 
 
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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