tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,210
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I'd like a macro that when i run it it opens the save as dialog box and defaults to XLSM
the file name is in activesheet "D17" and is written as just the name so "Tony Test1" for example,
so i'd like the dialog box to have "Tony Test 1" in the save as name area and XLSM but everything I try give me XLSX
some of the file are being converted from XLSX to XLSM please help if you can.
I've attached the code I use, but feel free to give me your own if you wish
Heres my code:
I'd like a macro that when i run it it opens the save as dialog box and defaults to XLSM
the file name is in activesheet "D17" and is written as just the name so "Tony Test1" for example,
so i'd like the dialog box to have "Tony Test 1" in the save as name area and XLSM but everything I try give me XLSX
some of the file are being converted from XLSX to XLSM please help if you can.
I've attached the code I use, but feel free to give me your own if you wish
Heres my code:
VBA Code:
Sub SaveAs1()
Dim ws As Worksheet
Dim fileName As String
Dim saveAsDialog As FileDialog
Dim savePath As Variant
Set ws = ThisWorkbook.ActiveSheet
fileName = ws.Range("F17").Value
Set saveAsDialog = Application.FileDialog(msoFileDialogSaveAs)
saveAsDialog.Title = "Please choose location to save this document"
If InStrRev(fileName, ".xlsm") = 0 Then
fileName = fileName & ".xlsm"
End If
saveAsDialog.InitialFileName = fileName
If saveAsDialog.Show = -1 Then
savePath = saveAsDialog.SelectedItems(1)
ThisWorkbook.SaveAs fileName:=savePath
MsgBox "Document has been saved"
ws.Range("D19").Value = "Saved"
Call RoleM_show
MsgBox "You can now start building the Role Matrix data.", , ""
Else
MsgBox "Document not saved!"
End If
End Sub