3

我正在尝试将此代码保存到打开文件的目录中。目前它设法通过 cel 文本保存文件,但默认情况下希望保存在 c:/my 文档中。

这是我到目前为止所拥有的,不知道在哪里添加 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
4

1 回答 1

1

改变你GetSaveAsFilename

flToSave = Application.GetSaveAsFilename _
(ThisWorkbook.Path & "\" & flName, filefilter:="Excel Files (*.xlsm), *.xlsm", _
Title:="Save FileAs...")

这将SaveAs在指定目录中启动

于 2012-10-16T08:23:54.083 回答