You can copy this code to your new button_click routine
I tested it and it works for me.
Change Sheet3 and Sheet4 to meet your own needs.
The folder dialog code came from here.
Option Explicit
'Private Sub button_click()
Private Sub test73622125()
Dim fldr As FileDialog, fso As Object
Dim sFilename$, sItem$
Dim wb As Workbook
Dim WS As Worksheet
'create folder dialog
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
sFilename = ""
With fldr
.Title = "Please select a folder in which to create a copy of this workbook for a student"
.AllowMultiSelect = False
.InitialFileName = ThisWorkbook.Path
If .Show <> -1 Then
Call MsgBox("No folder selected. No copy created", vbOKOnly, "Warning")
Exit Sub
Else
'the new copy must have a different name so this code can open it immediately.
' Excel will not open two documents with the same name simultaneously
sFilename = .SelectedItems(1) & "\" & Replace(ThisWorkbook.Name, ".xlsm", " Copy.xlsm")
End If
End With
'copy file, courtesy of Dominique
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile ThisWorkbook.FullName, sFilename
'open newly copied document
Set wb = Workbooks.Open(FileName:=sFilename)
'change Sheet3 and 4 to the the sheets students should not see
For Each WS In wb.Sheets
If WS.Name = "Sheet3" Or WS.Name = "Sheet4" Then
Application.DisplayAlerts = False
WS.Delete
Application.DisplayAlerts = True
End If
Next
'save and close new copy for student
Application.DisplayAlerts = False
wb.Close (True)
Application.DisplayAlerts = True
End Sub