【问题标题】:Saving an XLSM file as any file name, format, and directory将 XLSM 文件保存为任何文件名、格式和目录
【发布时间】:2015-11-19 11:44:19
【问题描述】:

我正在寻找一个宏来将当前打开的 XLSM 文件另存为具有以下条件的 XLSM 文件。

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

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

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

所以基本上我希望能够保存文件,就像我在不使用宏的情况下执行普通的另存为文件一样。

我已经看到了许多不同的宏,它们可以满足我的部分请求,但在所有条件下都没有。

【问题讨论】:

    标签: vba excel save-as


    【解决方案1】:

    使用文件对话框:

    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.htmhttps://msdn.microsoft.com/fr-fr/library/office/ff841185.aspx

    【讨论】:

    • 完全符合我的要求。我只是认为这样做需要更多的代码。非常感谢!
    猜你喜欢
    • 2021-07-11
    • 1970-01-01
    • 2020-04-21
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    相关资源
    最近更新 更多