我正在尝试将此代码保存到打开文件的目录中。目前它设法通过cel文本保存文件,但默认情况下要保存在c:/ my documents中。
这是我到目前为止所不知道在哪里添加ThisWorkbook.Path
Sub Save()
Dim flToSave As Variant
Dim flName As String
Dim flFormat As Long
flFormat = ActiveWorkbook.FileFormat
flName = Range("A1") & Range("A2").Text
flToSave = Application.GetSaveAsFilename _
(flName, filefilter:="Excel Files (*.xlsm), *.xlsm", _
Title:="Save FileAs...")
If flToSave = False Then
Exit Sub
Else
Thisworkbook.SaveAs Filename:=flToSave, FileFormat:=flFormat
End If
End Sub
答案 0 :(得分:1)
将GetSaveAsFilename
更改为
flToSave = Application.GetSaveAsFilename _
(ThisWorkbook.Path & "\" & flName, filefilter:="Excel Files (*.xlsm), *.xlsm", _
Title:="Save FileAs...")
这将启动指定目录中的SaveAs