Hi,
I have a workbook with ALOT of data/formulas/forms etc.
I HAD a macro that would allow users to press a button and then save the file as a marco free workbook. Before this it would do the following with the original workbook :
Remove all formulas and replace them with values
Clear all defined names
Clear all buttons
Clear all shapes
Copies the graphs as images and deletes originals
Delete 3 sheet with data
It would then save copy of the workbook (xlsm), open up that copy and save it as xlsx then close it. Then delete the xlsm, then open up the xlsx.
The the the original workbook would be closed without saving changes.
Thus the user if left with all their data but not of the formulas etc.
Below is the section of code that deals with the copying of the workbook (after the changes to the original have been made) , any advice or suggestions would be appreciated
Sub Data_Transfer_Workbook_User()
Dim strFullName As String
Dim strNewCopy As String
Dim wkbNewCopy As Workbook
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
Sheets("Tank Data & Service Details").Select
With ThisWorkbook
With .Worksheets("Macros")
.Visible = xlSheetVisible
.Delete
End With
With .Worksheets("PARAMETERS")
.Visible = xlSheetVisible
.Delete
End With
With .Worksheets("MENU")
.Visible = xlSheetVisible
.Delete
End With
strFullName = .FullName
strNewCopy = Environ("USERPROFILE") & "\Desktop\" & "Tank " & Sheets("Tank Data & Service Details").Range("D19").Value & " EEMUA 159 - Complete"
.SaveCopyAs strNewCopy & ".xlsm"
End With
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Set wkbNewCopy = Workbooks.Open(strNewCopy)
wkbNewCopy.SaveAs strNewCopy, FileFormat:=xlOpenXMLWorkbook
wkbNewCopy.Close
Kill strNewCopy & ".xlsm"
Workbooks.Open (strNewCopy & ".xlsx")
' Close the original workbook without saving changes
With ThisWorkbook
Application.DisplayAlerts = False ' Disable alerts to avoid the save prompt
.Close False ' Close the workbook without saving changes
Application.DisplayAlerts = True ' Enable alerts back
End With
End Sub
Bookmarks