I want to open the saveas dialog to save a workbook using VBA.
I've created the code below but it doesn't work.
"methode 'execute' of object 'filedialog' failed"
Has anyone an idee what goes wrong ?
I've created the code below but it doesn't work.
"methode 'execute' of object 'filedialog' failed"
Has anyone an idee what goes wrong ?
Code:
Sub SaveWorkbook()
Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
.FilterIndex = 2
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
.Title = "Choose file location..."
.InitialFileName = "save_test" & ".xlsm"
If .Show = -1 Then .Execute
End With
Set fd = Nothing
End Sub