如何打开从我的邮箱中下载并在Winzip中解压缩的Excel文件?

我正在做一个满足两个条件的项目。 我必须从我的邮箱下载一个Winzip附件,然后成功解压缩,然后打开该文件。 我已经完成了前两个部分,但是我无法打开文件。 问题是与文件的名称。 我无法在macros中指定文件的名称。 以下是使用的代码:

Sub FebAttachment_Click() Const olFolderInbox As Integer = 6 Const AttachmentPath As String = "D:\Documents and Settings\rahul.baskaran\Desktop\" Dim oApp As Object, ONS As Object, OInb As Object Dim OItem, OAtch As Object Dim OFind As Object Dim OMail As Object Set oApp = GetObject(, "Outlook.application") Set ONS = oApp.GetNamespace("MAPI") Set OInb = ONS.Folders("Archive Folders").Folders("BIZOPS").Folders("2014.02") Set OMail = OInb.Items For Each OItem In OInb.Items If OItem.Attachments.Count <> 0 Then For Each OAtch In OItem.Attachments OAtch.SaveAsFile AttachmentPath & OAtch.Filename Exit For Next Else MsgBox "The mail doesn't have an attachment" End If Exit For Next` Dim FSO As Object Dim Fname As Variant Dim FileNameFolder As Variant Dim DefPath As Variant Dim EXCELApplication As Object Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _ MultiSelect:=False) If Fname = False Then 'Do nothing Else DefPath = "D:\Documents and Settings\rahul.baskaran\Desktop\" If Right(DefPath, 1) <> "\" Then DefPath = DefPath & "\" End If Set oApp = CreateObject("Shell.Application") oApp.Namespace(DefPath).CopyHere oApp.Namespace(Fname).Items DoEvents Set EXCELApplication = CreateObject("Excel.Application") EXCELApplication.Workbooks.Open (DefPath & "\22 ABC Feb BVA as of 25th-Nov-13 Sigma .xlsb") EXCELApplication.Visible = True End Sub 

一切正如预期的这个代码工作。 但在下面的路线。 我想自动化文件的名称,然后打开文件。 我无法执行此操作。

EXCELApplication.Workbooks.Open (DefPath & "\22 ABC Feb BVA as of 25th-Nov-13 Sigma .xlsb")

有人可以帮我以下2点?

1)是否有可能提取文件没有我手动使用Application.GetOpenFilename函数select文件?

2)我希望提取的文件一旦被提取成功就自动打开。 任何其他编码方法也是受欢迎的。

这条线的问题是额外的\

DefPath已经评估为"D:\Documents and Settings\rahul.baskaran\Desktop\"所以DefPath & "\22 ABC Feb BVA as of 25th-Nov-13 Sigma .xlsb"会给你

D:\Documents and Settings\rahul.baskaran\Desktop\\22 ABC Feb BVA as of 25th-Nov-13 Sigma .xlsb"

注意22日前的? 改变你的代码

EXCELApplication.Workbooks.Open (DefPath & "22 ABC Feb BVA as of 25th-Nov-13 Sigma .xlsb")