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中啓動? –