未找到 Outlook Application.FileDialog [英] Outlook Application.FileDialog not found

查看:34
本文介绍了未找到 Outlook Application.FileDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Outlook 编写 VBA 宏,但 Application.FileDialog 方法不可用.

I'm writing a VBA macro for Outlook and the Application.FileDialog method is not available.

目的是让用户选择一个文件夹 - 不是 Outlook 电子邮件文件夹,而是文件系统目录文件夹.

The intent is for the user to select a folder - not an Outlook email folder, but a file system directory folder.

以下是我启用的参考:

  • Visual Basic for Applications Microsoft Outlook 15.0 对象库
  • Microsoft Office 15.0 对象库 OLE 自动化 Microsoft Forms
  • Microsoft Office 15.0 对象库
  • OLE 自动化 Microsoft Forms 对象库
  • Microsoft 脚本运行时
  • Microsoft Office 15.0 Access 数据库引擎对象库

有什么想法吗?

推荐答案

Outlook 不支持 FileDialog 对象.解决方法如下:

Outlook doesn't support the FileDialog object. Here's a workaround:

Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = False

Dim fd As Office.FileDialog
Set fd = xlApp.Application.FileDialog(msoFileDialogFilePicker)

Dim selectedItem As Variant

If fd.Show = -1 Then
    For Each selectedItem In fd.SelectedItems
        Debug.Print selectedItem
    Next
End If

Set fd = Nothing
    xlApp.Quit
Set xlApp = Nothing

这篇关于未找到 Outlook Application.FileDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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