![](/img/trans.png)
[英]Macro for getting the file name from the cell and prompt the location to save the file
[英]Save As To Prompt For Location But Use Filename From Cell
我從論壇上得到了這段代碼,它可以工作,但我需要調整它以顯示“另存為”框,但我的名稱已經填充了我的變量 FName。
有人可以幫我弄這個嗎?
Sub Save_New()
Dim FName As String
Dim FPath As String
'FPath = "C:"
FName = Sheets("Sheet1").Range("A1").Text
ThisWorkbook.SaveAs Filename:=FName
End Sub
您可以使用Application.GetSaveAsFilename 方法...
Option Explicit
Sub Save_New()
Dim FName As String
FName = Sheets("Sheet1").Range("A1").Text
Dim DialogResult As Variant 'variant is needed because the dialog returns FALSE if users presses cancel.
DialogResult = Application.GetSaveAsFilename(InitialFilename:=FName)
If Not DialogResult = False Then
ThisWorkbook.SaveAs Filename:=DialogResult
Else
'user clicked cancel
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.