Save a file

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,132
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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