简体   繁体   English

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

[英]Saving an XLSM file as any file name, format, and directory

I am looking for a macro to save a currently open XLSM file as something other than the XLSM file with the below conditions. 我正在寻找一个宏,用于将当前打开的XLSM文件另存为具有以下条件的XLSM文件以外的其他文件。

  1. I want to be able to save the file as any name. 我希望能够将文件另存为任何名称。

  2. I want to be able to save the file as any format. 我希望能够将文件保存为任何格式。

  3. I want to be able to choose the directory where it is save. 我希望能够选择保存目录。

So basically I want to be able to save the file just like I would do a normal Save As file without using a macro. 因此,基本上,我希望能够像不使用宏一样执行普通另存为文件一样保存文件。

I have seen a number of different macros out there that do parts of my request but nothing with all the conditions. 我已经看到了许多不同的宏,它们可以执行部分​​请求,但在所有条件下均不起作用。

Using FileDialog : 使用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 

To use SaveAs , take a look : http://www.rondebruin.nl/win/s5/win001.htm and https://msdn.microsoft.com/fr-fr/library/office/ff841185.aspx 要使用SaveAs ,请看一下: http : //www.rondebruin.nl/win/s5/win001.htmhttps://msdn.microsoft.com/fr-fr/library/office/ff841185.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM