I want the user to save the current macro file as a non-macro Excel file. The user controls the file name and file location on a shared network. In the code below, I cannot get the current macro file name to populate the file name window of the Save As dialog box.
Otherwise, the code seems to work, because I can see the 3 Excel format options in the Save as Type window.
I have also tried (InitialFileName:=txtFileName,…), as well as (, Filefilter:=…) and (Filefilter:=…). Each time, the save-as box opens with nothing in the filename window. What am I missing?
My code:
Thank you. I hope you can help.
Otherwise, the code seems to work, because I can see the 3 Excel format options in the Save as Type window.
I have also tried (InitialFileName:=txtFileName,…), as well as (, Filefilter:=…) and (Filefilter:=…). Each time, the save-as box opens with nothing in the filename window. What am I missing?
My code:
Rich (BB code):
‘Eliminate the macro file extension.
txtMacroFile = ActiveWorkbook.Name
txtFileName = Replace (txtMacroFile, ".xlsm", "")
'Display the saveas dialog box with xlsx as default format
FileName = Application.GetSaveAsFilename(txtFileName, FileFilter:= _
" Excel Macro Free Workbook (*.xlsx), *.xlsx," & _
" Excel 2000-2003 Workbook (*.xls), *.xls," & _
" Excel Binary Workbook (*.xlsb), *.xlsb")
If FileName = "False" Then Exit Sub
ActiveWorkbook.SaveAs FileName:=FileName
Thank you. I hope you can help.