I did some research on this, and I thought for sure that this would work, but it still saves as a macro-enabled file...
The only thing I've done is to put a "1" in place of a string which is set as a constant at the beginning of my entire project, and I've moved a few of the variables and their declarations into this subroutine (so, changed from "Global" to "Dim").Sub ExportData() Dim FileDate As String Dim FileName As String Dim ReportDate as Date Dim FilePath as String Dim FinalBook as String Application.DisplayAlerts = False ThisWorkbook.CheckCompatibility = False ReportDate = (Date - 1) FilePath = ThisWorkbook.Path & "\" FinalBook = "Report - " 'Set up file name FileDate = Format(ReportDate, "mm-dd-yy") FileName = FilePath & FinalBook & FileDate 'Select only the sheet with the final data and save as separate non-macro-enabled file ThisWorkbook.Worksheets(1).Copy ActiveWorkbook.SaveAs FileName:=FileName, FileFormat:=xlOpenXMLWorkbook ActiveWorkbook.Close Application.DisplayAlerts = True End Sub 'ExportData
I'm working in Excel 2016, but this file may also be used by others working with Excel 2010, so it needs to work for both.
Bookmarks