我找到了一个宏,可以自动从某些电子邮件中下载附件。现在我想在文件下载后运行批处理文件。我想知道如何让两个模块都运行?它们需要位于同一个模块上吗?
这是我的代码:
模块名称 - 下载
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "C:\Users\username\Documents\"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
模块名称-RunBat
Sub CallOtherProgram()
Shell "C:\Users\username\Desktop\BatchFile.bat", vbNormalFocus
End Sub
有什么办法可以让它们一个接一个地运行吗?我对脚本编写还很陌生。
谢谢!
答案1
CallOtherProgram
只需在原始程序中添加一个调用:
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "C:\Users\username\Documents\"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
CallOtherProgram
End Sub