Is it possible to eliminate the Save As dialog from appearing, but instead use a input box to enter the new report name then Save As xlsm within same ActiveWorkbook in separate folder that is named “Saved Reports†I also would still like to have the master workbook close and new report stay open.
Code: Select all
If Application.Dialogs(xlDialogSaveAs).Show(arg2:=xlOpenXMLWorkbookMacroEnabled) Then
Dim WSHShell As Object
Dim strDesktopPath As String
Set WSHShell = CreateObject("WScript.Shell")
' Read desktop path using WshSpecialFolders object
strDesktopPath = WSHShell.SpecialFolders("Desktop")
If Not Right(strDesktopPath, 1) = "\" Then
strDesktopPath = strDesktopPath & "\"
End If
With WSHShell.CreateShortcut(strDesktopPath & "\" & ActiveWorkbook.Name & ".lnk")
' Set shortcut object properties and save it
.TargetPath = ActiveWorkbook.FullName
.Save
End With
Set WSHShell = Nothing
Else
MsgBox ("You have selected cancel")
End If
Code: Select all
Dim wbOld As Workbook 'refers to master workbook
Dim wbNew As Workbook 'refers to new workbook
Dim nwb As String 'refers to input box
On Error GoTo EH
Application.ScreenUpdating = False
Application.EnableEvents = False
nwb = Application.InputBox("Enter new report name", "Starting a new report", Type:=2)
If nwb = "False" Then Exit Sub
Set wbOld = ThisWorkbook("master.xlsm")
With wbOld
.SaveAs
.FileFormat = xlOpenXMLWorkbookMacroEnabled
.Name = nwb
.TargetPath = "ActiveWorkbook.FullName\Saved Reports"
.Close
End With
Set wbNew = ActiveWorkbook
With wbn
.Save
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
EH: Exit Sub