Outlook(VBA)错误438中的打开文件对话框 [英] Open File Dialog in Outlook (VBA) Error 438

查看:145
本文介绍了Outlook(VBA)错误438中的打开文件对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过VBA在Outlook中打开文件对话框. (Outlook 2010)

I'm trying to open a File Dialog in Outlook via VBA. (Outlook 2010)

使用以下代码,我得到一个错误:

With the following code i get an Error:

运行时错误438.对象不支持此属性或方法

Runtime error 438. Object doesn't support this property or method

Private Sub btn_openPST_Click()
    Dim oFileDialog As FileDialog
    Set oFileDialog = myAppl.FileDialog(msoFileDialogFilePicker)
    With oFileDialog
        .Title = "Select your PST File"
        .ButtonName = "Ok"
        .Show
    End With
End Sub

myAppl是一个Outlook.Application对象:

myAppl is an Outlook.Application Object:

Dim myAppl As Outlook.Application
Set myAppl = CreateObject("Outlook.Application")

推荐答案

我认为Outlook无法打开文件选择器.我的解决方法是先打开Excel工作表,然后打开文件选择器,然后关闭Excel工作表.尝试下面的代码,并确保将"Microsoft Excel 14.0对象库" 参考导入Outlook.

I don't think Outlook can open a file picker. I workaround is to open an Excel sheet and then open the file picker, then close the excel sheet. Try the following code, and be sure to import the "Microsoft Excel 14.0 Object Library" Reference into Outlook.

Private Sub openFDinOutlook()

    Dim xlObj As Excel.Application
    Dim fd As Office.FileDialog

    Set xlObj = New Excel.Application
    xlObj.Visible = False
    Set fd = xlObj.Application.FileDialog(msoFileDialogFolderPicker)
    With fd
        .Title = "Select your PST File"
        .ButtonName = "Ok"
        .Show
    End With
    xlObj.Quit
    Set xlObj = Nothing


End Sub

这篇关于Outlook(VBA)错误438中的打开文件对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆