Hi All, I have some code that copies a macro enabled workbook to an .xlsx format. The original file has some form controls on it, and I would like to include some code to delete the controls. The code to copy the workbook is below. What I am looking to do is to delete the form controls from the destination workbook (Destwb). How can I do it...?
VBA Code:
Dim Sourcewb As Workbook
Dim Destwb As Workbook
With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
Dim answer As Integer
answer = MsgBox("File will be saved in .xlsx format in original file location." & vbCr & vbCr & _
"Email will be prepared. Please attach any supplemental information", vbOKCancel + vbInformation, "File Save Location")
If answer = vbCancel Then
Exit Sub
Else:
Set Sourcewb = ActiveWorkbook
Sheets.Copy 'Copy the ActiveSheet to a new workbook
Set Destwb = ActiveWorkbook
'Determine the Excel version and file extension/format
With Destwb
If Val(Application.Version) < 12 Then
'You use Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007-2016
FileExtStr = ".xlsx": FileFormatNum = 51
End If
End With