【发布时间】:2014-01-10 16:49:02
【问题描述】:
我尝试使用以下代码将 Outlook 附件导出到 Excedl:
Public bCancel As Boolean
Public dDate As Date
Public sPath As String
Public Sub TESTMACRO()
Dim MyOlApp As New Outlook.Application
Dim MyOlExp As Outlook.Explorer
Dim MySelection As Outlook.Selection
Dim msg As MailItem
Dim amount As Long
Set MyOlExp = MyOlApp.ActiveExplorer
Set MySelection = MyOlExp.Selection
amount = MySelection.Count
bCancel = True
TESTMACROX.Show
If Not bCancel Then
If amount = 1 Then
WaitFinish.Show (False)
Dim objTesteInforme As New TesteInforme
objTesteInforme.fecha = dDate
objTesteInforme.path = sPath
' Procesamos el mensaje seleccionado
If MySelection.Item(1).Class = olMail Then
' El objeto seleccionado es un correo
Set msg = MySelection.Item(1)
If InStr(1, msg.Subject, "YYYYY") > 0 And InStr(1, msg.Subject, "ZZZZZ") > 0 Then
' Se trata de un mensaje de xxxxxxxxxxxxxxxxxx
objTesteInforme.CLIENTE = "YYYYYZZZZZ"
If (Not objTesteInforme.GeneraTestMacro(msg)) Then
' El procesamiento fracasó
MsgBox "El procesamiento del mensaje " & msg.Subject & " fracasó; por favor, revisa el formato del archivo adjunto", vbCritical
End If
Else
MsgBox "El mensaje " & msg.Subject & " no se reconoce como diario Batch de ningún cliente", vbCritical
End If
End If
Set msg = Nothing
Else
MsgBox "Por favor, selecciona un correo electrónico", vbExclamation
End If
WaitFinish.Hide
Else
MsgBox "Por favor selecciona uno y solo un mesaje. Gracias", vbExclamation
End If
Set MySelection = Nothing
Set MyOlExp = Nothing
End Sub
问题是我只选择了一条消息,主题为 YYYYY ZZZZZ - LLLLLLL: 140109,但它没有打开带有附件的 Excel 工作表,而是发送错误消息“Por喜爱selecciona uno y solo un mesaje。Gracias” .为什么?
【问题讨论】: