我有一个excel文件。我想在 VBA 中编写代码,并且此代码将 sheet3 作为副本保存在特定目录中。文件格式正常(.xlsx)。此外,此代码将 sheet3 保存为特定目录中的 pdf。我制作了这段代码,但是当运行这段代码时,它会打开我最近的保存文件并关闭我的主文件。我试图解决这个问题。但我无法修复它。所以需要帮助。
Sub Saveasdailog()
On Error Resume Next
With Application.FileDialog(msoFileDialogSaveAs)
.Title = "Location file and file Name Enter"
.ButtonName = "Save Invoice"
.InitialFileName = "E:\Execl Documents\Business management file\Edit invoice\" & Range("F9").Value
If .Show = 0 Then
MsgBox "The file did not save.", vbCritical
Exit Sub
End If
Application.DisplayAlerts = False
.Execute
Application.DisplayAlerts = True
End With
End Sub
只有另存为代码。
我希望我的代码一次做两件事。一种是另存为并保存pdf。