将XLSM文件保存为任何文件名,格式和目录

我正在寻找一个macros来保存当前打开的XLSM文件,而不是以下条件的XLSM文件。

  1. 我希望能够以任何名称保存文件。

  2. 我希望能够以任何格式保存文件。

  3. 我希望能够select保存的目录。

所以基本上我想能够保存文件,就像我会做一个正常的另存为文件,而不使用macros。

我已经看到了一些不同的macros,这些macros执行我的请求的一部分,但没有任何条件。

使用FileDialog:

Sub Example1() Dim intChoice As Integer Dim strPath As String 'make the file dialog visible to the user intChoice = Application.FileDialog(msoFileDialogSaveAs).Show 'determine what choice the user made If intChoice <> 0 Then 'get the file path selected by the user strPath = _ Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1) 'displays the result in a message box Call MsgBox(strPath, vbInformation, "Save Path") End If End Sub 

要使用SaveAs ,请看一下: http : //www.rondebruin.nl/win/s5/win001.htm和https://msdn.microsoft.com/fr-fr/library/office/ff841185.aspx