Hey all,
Long time lurker posting for the first time.
I'm having a real hard time trying to make msoFileDialogSaveAs to pre select the file format of the Save As dialog based on the current file format. Basically, if the current file is .xlsm, I would like that the dialog pre selected the .xlsm format or whatever the format of the current file, .csv, .xlsx, etc.
As you can note in the following image, my code is not working properly: http://i.imgur.com/8LSyTWW.png (please note x.xlsm on the top of the screen vs the .xlsx in the file type selector).
The sub:
Set dlgFile = Application.FileDialog(msoFileDialogSaveAs)
dlgFile.title = "Neat Addin"
With dlgFile
.InitialFileName = CurrentDate & "_" & FName & "_v1.1_" & MyInit
If .Show = -1 Then
myFileName = .SelectedItems(1)
End If
End With
Set dlgFile = Nothing
'Name checking ends
End If
'Save file
ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=ActiveWorkbook.FileFormat
This is only part of the code. All the variables are being called and the sub works perfectly if the file I'm saving is already in xlsx.
Any thoughts?
Thanks a lot. Best,
Long time lurker posting for the first time.
I'm having a real hard time trying to make msoFileDialogSaveAs to pre select the file format of the Save As dialog based on the current file format. Basically, if the current file is .xlsm, I would like that the dialog pre selected the .xlsm format or whatever the format of the current file, .csv, .xlsx, etc.
As you can note in the following image, my code is not working properly: http://i.imgur.com/8LSyTWW.png (please note x.xlsm on the top of the screen vs the .xlsx in the file type selector).
The sub:
Set dlgFile = Application.FileDialog(msoFileDialogSaveAs)
dlgFile.title = "Neat Addin"
With dlgFile
.InitialFileName = CurrentDate & "_" & FName & "_v1.1_" & MyInit
If .Show = -1 Then
myFileName = .SelectedItems(1)
End If
End With
Set dlgFile = Nothing
'Name checking ends
End If
'Save file
ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=ActiveWorkbook.FileFormat
This is only part of the code. All the variables are being called and the sub works perfectly if the file I'm saving is already in xlsx.
Any thoughts?
Thanks a lot. Best,