Excel 2010中& SSIS 2012 - 当Outlook打开,宏跑了,我得到一个运行时错误429 - 的ActiveX无法创建对象......当Outlook关闭宏执行如预期 - 下来装载两个微型报告开始和结束的xlsx所有附件。VBA宏获得Outlook附件只能当Outlook关闭
SSIS包打开的Excel与宏文件,但随后返回该ActiveX错误。同样,如果Outlook关闭,SSIS包打开的Excel,运行宏(下载文件),并在我们的共享驱动器的目录保存它们。
我有什么编码的需要的Outlook被关闭?
VBA代码如下:
Sub GetAttachments()
Dim olapp As Object
Dim olmapi As Object
Dim olmail As Object
Dim olitem As Object
Dim lrow As Integer
Dim olattach As Object
Dim FileName As String
Const num As Integer = 6
Const path As String = "Y:\Wireline Forecast\MiniReport - Production\Mini Report Region Automation\Load Files\"
Const strFileType As String = "xlsx"
Set olapp = CreateObject("outlook.application")
Set olmapi = getnamespace("MAPI")
Set olmail = olmapi.getdefaultfolder(num)
If olmail.Items.restrict("[UNREAD]=True").Count = 0 Then
MsgBox ("No Unread mails")
Else
For Each olitem In olmail.Items.restrict("[UNREAD]=True")
If olitem.attachments.Count <> 0 Then
For Each olattach In olitem.attachments
If Left(olattach.FileName, 11) = "Mini Report" And Right(olattach.FileName, 4) = "xlsx" Then
FileName = "Y:\Wireline Forecast\MiniReport - Production\Mini Report Region Automation\Load Files\" & olattach.FileName
olattach.SaveAsFile FileName
End If
Next olattach
End If
Next olitem
End If
End Sub
IT有它锁定,所以没有为管理员所以这两个方案应在相同的安全级别运行运行的能力。 – Robdenham
如何Excel和Outlook中启动? –