atreidies
asked on
Save As Without any macros or modules
I am using:
Application.Dialogs(xlDial ogSaveAs). Show ("M:\ExcelCopies\File1.xls ")
to save a copy and not alter the original. But I need to remove the On_Open Event from the Save As Copy.
Application.Dialogs(xlDial
to save a copy and not alter the original. But I need to remove the On_Open Event from the Save As Copy.
Rather than showing the SaveAs dialog, I prefer to use the GetSaveAsFileName method. This displays the file browser dialog and can default the file name for you--but it doesn't actually save the file. You do that separately using something like the previously suggested code.
The snippet shows code that you might use in Excel 2003 through 2010 to display the file browser and let the user pick a name. As shown, it defaults to the current name of the file--change the ThisWorkbook.Name to get a different default.
Brad
The snippet shows code that you might use in Excel 2003 through 2010 to display the file browser and let the user pick a name. As shown, it defaults to the current name of the file--change the ThisWorkbook.Name to get a different default.
Brad
'The FileFilter parameter eliminates the double quotes surrounding the default file name in the GetSaveAsFilename dialog, _
provided that the existing file extension matches the default filter. _
You get the text for the FileFilter from the File...Save As dialog. Look in the "Save as type" field. _
Feel free to change the text before the comma. The comma and text following it must match exactly, however!
flPath = Application.GetSaveAsFilename(ThisWorkbook.Name, FileFilter:="Excel workbook (*.xls),*.xls,Excel workbook (*.xlsx),*.xlsx", _
FilterIndex:=IIf(ThisWorkbook.Name Like "*.xls", 1, 2))
'You don't need the FilterIndex parameter if there is only one filter type. _
The Iif function is like the worksheet IF function. It defaults the file type according to the current file name.
If flPath = "False" Then Exit Sub 'GetSaveAsFilename returns "False" if user clears the file name field
ASKER
We are unable to open .xlsx files.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked...Thanks
Brad
Open in new window