【发布时间】:2020-07-30 08:48:03
【问题描述】:
我已经被这个问题困扰了一段时间,非常感谢您的帮助。
当工作簿关闭时,我已经有了这个概念,但它所做的只是保存到指定的位置。现在,我想对其进行调整,一旦按下按钮,它将要求用户保存到一个位置,然后保存后,excel 会将其保存到我选择的另一个位置。
按下按钮时,我不断收到错误消息“参数不是可选的”。
谢谢。
Private Sub Save(Cancel As Boolean)
NameOfWorkbook = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".", -1, vbTextCompare) - 1))
Dim varResult As Variant
'displays the save file dialog
varResult = Application.GetSaveAsFilename
'checks to make sure the user hasn't canceled the dialog
If varResult <> False Then
Cells(2, 1) = varResult
MyMsg = NameOfWorkbook + " " & "saved to return note folder"
MsgBox MyMsg
'Create and assign variables
Dim saveLocation As String
saveLocation = "S:\Office information\Returns\Return Notes\" + NameOfWorkbook
'Save Active Sheet(s) as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=saveLocation
End If
End Sub
【问题讨论】:
-
Private Sub Save(Cancel As Boolean)应该是Private Sub Save()