Save without Macros then delete old file (2007)

MNpoker

Board Regular
Joined
Dec 15, 2003
Messages
154
I have reports that go to customers and I want to save the file without macros for sending.

There is a 'main' file that runs analyses then saves a copy. The copy then has certain sheets changed to values and other sheets deleted.

I now want to save the new file as a nonmacro enable workbook.

Here is the code (Ithink the new code would go in at the bottom:
Rich (BB code):
Sub SaveCopyAs()
    Dim ThisBook As Workbook, WkSht As Worksheet
    Set ThisBook = ThisWorkbook
    Dim strFullPath As String
    Dim ReportName As String
    Dim sXL_Path As String
    
    strFullPath = Application.ActiveWorkbook.Path
    
    sXL_Path = Left(strFullPath, InStrRev(strFullPath, "\"))
    
    ReportName = Worksheets("Inputs").Range("B4")
    
     
    Application.ScreenUpdating = False
    ThisBook.SaveCopyAs Filename:=strFullPath & "\GeneratedReports\" & ReportName & ".xlsm"
   
    Application.Workbooks.Open strFullPath & "\GeneratedReports\" & ReportName & ".xlsm"
    
    ' Paste Values

 .............
            
     Application.DisplayAlerts = False
    
    ' DELETE WorkSHEETS
    
    For Each WkSht In ActiveWorkbook.Worksheets
        Select Case WkSht.Name
             
             '***************************************
             'Sheets to be excluded (rename as required)
        Case "Inputs", "EP_MeanStDev", "AEP", "OEP", "BatchProcessing"
             '***************************************
             
            Application.DisplayAlerts = False
            WkSht.Delete
        Case Else
             'do nothing
        End Select
        Application.CutCopyMode = False
    Next WkSht

I think I have to do it here
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    MsgBox "Copy Saved as: " & strFullPath & "\GeneratedReports\" & ReportName & ".xlsm"
    
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Got it !!!!!!

ActiveWorkbook.SaveAs Filename:=strFullPath & "\GeneratedReports\" & ReportName, FileFormat:=51, CreateBackup:=False
Kill strFullPath & "\GeneratedReports\" & ReportName & ".xlsm"
ActiveWorkbook.Close
MsgBox "Copy Saved as: " & strFullPath & "\GeneratedReports\" & ReportName & ".xlsx"
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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