vba - VBA代码周末日期名称和特定文件夹并自动保存
问题描述
我需要帮助来修改此 VBA 代码以将 pdf 保存在特定文件夹中,并且我在一个名为 E 24 的单元格中计算了一个周末日期,或者如果它是另一种方式。有人可以帮忙吗?
Private Sub Picture2_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim v As Variant
v = Application.GetSaveAsFilename(Range("E24").value.Format, "PDF Files (*.pdf), *.pdf")
If Dir(v) <> "C:\Users\user\Desktop\work invoices" Then
If MsgBox("File already exists - do you wish to overwrite it?", vbYesNo, "File Exists") = vbNo Then
Exit Sub
End If
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, filename:=v, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, From:=1, To:=3, OpenAfterPublish:=False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "accounts@email.com"
.CC = ""
.BCC = ""
.Subject = "Job number 1868"
.Body = ""
.Attachments.Add v
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End If
End Sub
解决方案
推荐阅读
- node.js - 如何使用带有 https 的 socket.io
- android - 使用风味在 AppGallery 和 Google Play 上发布应用
- python - 使用自定义开始/结束日期显示多年的数据 - datetime, matplotlib
- big-o - 我的代码在大 O 表示法中的复杂性是多少
- python - QIcon 的 PyQt5 “Ghost”出现在 QComboBox 的 QLineEdit 中
- c - Swift - 将转义闭包传递给 C API 回调
- ionic-framework - NFC Mifare Ultralight 伪造响应数据
- arrays - 如何在Excel中混合动态数组和常量数组
- c# - DataGrid 文本框 DataTrigger 条件未按预期工作
- python - python3:在“datetime.timedelta”和“str”的实例之间不支持