我正在尝试使用VBA打开指定目录下的.msg文件,但我一直收到运行时错误。
我的代码如下:
这是一个运行时错误:
“运行时错误'-2147287038(80030002)':无法打开文件:AUTO Andy Low Yong Cheng不在办公室(将于2014年9月22日返回)。msg。该文件可能不存在,您可能没有打开它的权限,或者它可能正在另一个程序中打开。右键单击包含该文件的文件夹,然后单击属性以检查您对该文件夹的权限。”
我的代码如下:
Sub bla()
Dim objOL As Object
Dim Msg As Object
Set objOL = CreateObject("Outlook.Application")
inPath = "C:\Users\SiliconPlus\Desktop\Si+ Contact Lists\Contact_Si+"
thisFile = Dir(inPath & "\*.msg")
Set Msg = objOL.CreateItemFromTemplate(thisFile)
' now use msg to get at the email parts
MsgBox Msg.Subject
Set objOL = Nothing
Set Msg = Nothing
End Sub
这是一个运行时错误:
“运行时错误'-2147287038(80030002)':无法打开文件:AUTO Andy Low Yong Cheng不在办公室(将于2014年9月22日返回)。msg。该文件可能不存在,您可能没有打开它的权限,或者它可能正在另一个程序中打开。右键单击包含该文件的文件夹,然后单击属性以检查您对该文件夹的权限。”
thisFile
的值再继续进行呢? - SierraOscar