Outlook的保存文件对话框在哪里?

发布于 2024-07-17 10:40:40 字数 213 浏览 7 评论 0原文

我正在开发一个 Outlook 加载项,它需要 Office 特定的 FileDialog 才能与 Sharepoint 站点进行互操作; 通用文件对话框不具有互操作性。 我知道Word和Excel在Globals.ThisAddIn.Application.Application下都有一个get_fileDialog方法,但Outlook似乎没有。 如何启动 Outlook 文件对话框? 有可能吗?

I'm working on an Outlook add-in that requires the Office specific FileDialog to interoperate with a Sharepoint site; the common file dialog doesn't have the interoperability. I know that both Word and Excel have a get_fileDialog method under Globals.ThisAddIn.Application.Application, but Outlook doesn't seem to. How do I launch an Outlook FileDialog? Is it even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

ら栖息 2024-07-24 10:40:40

Microsoft 通用对话框

如果您有 COMDLG32。安装了 OCX(“通用对话框 ActiveX 控件”),然后您就可以使用它 - 此处通过示例进行了解释。 (向下滚动到标题为“图 2:不要尝试在 Word 中选择多个文件!”的屏幕截图)。

Microsoft Common Dialog

If you have COMDLG32.OCX ("Common Dialog ActiveX Control") installed, then you can use this - it's explained here, with an example. (Scroll down just past the screenshot entitled "FIGURE 2: Don't try to select more than one file in Word! ").

自在安然 2024-07-24 10:40:40

Outlook 的应用程序对象似乎不提供FileDialog。 但如果您愿意获得 Excel 参考,一个简单的解决方法是:

Dim fd As FileDialog
Set fd = Excel.Application.FileDialog(msoFileDialogFolderPicker)
Dim folder As Variant    
If fd.Show = -1 Then
    For Each folder In fd.SelectedItems
        Debug.Print "Folder:" & folder & "."
    Next
End If

It appears that Outlook's Application object does not offer FileDialog. But a simple workaround, if you are willing to have an Excel reference, is:

Dim fd As FileDialog
Set fd = Excel.Application.FileDialog(msoFileDialogFolderPicker)
Dim folder As Variant    
If fd.Show = -1 Then
    For Each folder In fd.SelectedItems
        Debug.Print "Folder:" & folder & "."
    Next
End If
半夏半凉 2024-07-24 10:40:40
'Add a "Module". Then add the declarations like this to it.

Option Explicit
Private Declare Function GetOpenFileName _
                Lib "comdlg32.dll" _
                Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type

Public Function MyOpenFiledialog() As String
    Dim OFName As OPENFILENAME
    OFName.lStructSize = Len(OFName)
    'Set the parent window
    OFName.hwndOwner = Application.hWnd
    'Set the application's instance
    OFName.hInstance = Application.hInstance
    'Select a filter
    OFName.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
    'create a buffer for the file
    OFName.lpstrFile = Space$(254)
    'set the maximum length of a returned file
    OFName.nMaxFile = 255
    'Create a buffer for the file title
    OFName.lpstrFileTitle = Space$(254)
    'Set the maximum length of a returned file title
    OFName.nMaxFileTitle = 255
    'Set the initial directory
    OFName.lpstrInitialDir = "C:\"
    'Set the title
    OFName.lpstrTitle = "Open File - VB Forums.com"
    'No flags
    OFName.flags = 0
    'Show the 'Open File'-dialog
    If GetOpenFileName(OFName) Then
        MsgBox "File to Open: " + Trim$(OFName.lpstrFile)
        MyOpenFiledialog = Trim$(OFName.lpstrFile)
    Else
        MsgBox "Cancel was pressed"
        MyOpenFiledialog = vbNullString
    End If
End Sub 'Usage:
Private Sub Command1_Click()
    Text1.Text = MyOpenFiledialog
End Sub
'Add a "Module". Then add the declarations like this to it.

Option Explicit
Private Declare Function GetOpenFileName _
                Lib "comdlg32.dll" _
                Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type

Public Function MyOpenFiledialog() As String
    Dim OFName As OPENFILENAME
    OFName.lStructSize = Len(OFName)
    'Set the parent window
    OFName.hwndOwner = Application.hWnd
    'Set the application's instance
    OFName.hInstance = Application.hInstance
    'Select a filter
    OFName.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
    'create a buffer for the file
    OFName.lpstrFile = Space$(254)
    'set the maximum length of a returned file
    OFName.nMaxFile = 255
    'Create a buffer for the file title
    OFName.lpstrFileTitle = Space$(254)
    'Set the maximum length of a returned file title
    OFName.nMaxFileTitle = 255
    'Set the initial directory
    OFName.lpstrInitialDir = "C:\"
    'Set the title
    OFName.lpstrTitle = "Open File - VB Forums.com"
    'No flags
    OFName.flags = 0
    'Show the 'Open File'-dialog
    If GetOpenFileName(OFName) Then
        MsgBox "File to Open: " + Trim$(OFName.lpstrFile)
        MyOpenFiledialog = Trim$(OFName.lpstrFile)
    Else
        MsgBox "Cancel was pressed"
        MyOpenFiledialog = vbNullString
    End If
End Sub 'Usage:
Private Sub Command1_Click()
    Text1.Text = MyOpenFiledialog
End Sub
寄与心 2024-07-24 10:40:40
Public Sub TestFileDialog()
    Dim otherObject As Excel.Application
    Dim fdFolder As office.FileDialog

    Set otherObject = New Excel.Application
    otherObject.Visible = False
    Set fdFolder = otherObject.Application.FileDialog(msoFileDialogFolderPicker)
    fdFolder.Show
    Debug.Print fdFolder.SelectedItems(1)
    otherObject.Quit
    Set otherObject = Nothing
End Sub
Public Sub TestFileDialog()
    Dim otherObject As Excel.Application
    Dim fdFolder As office.FileDialog

    Set otherObject = New Excel.Application
    otherObject.Visible = False
    Set fdFolder = otherObject.Application.FileDialog(msoFileDialogFolderPicker)
    fdFolder.Show
    Debug.Print fdFolder.SelectedItems(1)
    otherObject.Quit
    Set otherObject = Nothing
End Sub
人海汹涌 2024-07-24 10:40:40
Private Sub multiEML2MSG()

Const PR_ICON_INDEX = &H10800003

Dim objPost As Outlook.PostItem
Dim objSafePost As Redemption.SafePostItem
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder


Set objNS = Outlook.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objPost = objInbox.Items.Add(OlItemType.olPostItem)

Set objSafePost = New Redemption.SafePostItem



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

    Set xlObj = New Excel.Application

    Set fd = xlObj.Application.FileDialog(msoFileDialogFolderPicker)
    With fd
        .Title = "Select your PST File"
        .ButtonName = "Ok"
        .Show

        If fd.SelectedItems.Count <> 0 Then
            xDirect$ = fd.SelectedItems(1) & "\"
            xFname$ = Dir(xDirect$, 7)


            licznik = 1
            Do While xFname$ <> ""

            XPathEML = xDirect$ & xFname$
            XPathMSG = Replace(XPathEML, ".eml", ".msg", , , vbTextCompare)
            Debug.Print XPath, Replace(XPath, ".eml", ".msg", , , vbTextCompare)


            objPost.Save
            objSafePost.Item = objPost
            objSafePost.Import XPathEML, Redemption.RedemptionSaveAsType.olRFC822
            objSafePost.MessageClass = "IPM.Note"
            objSafePost.Fields(PR_ICON_INDEX) = none
            objSafePost.SaveAs XPathMSG, Outlook.OlSaveAsType.olMSG



            xFname$ = Dir
            licznik = licznik + 1
        Loop

        End If
    End With

    xlObj.Quit
    Set xlObj = Nothing
    Set objSafePost = Nothing
    Set objPost = Nothing
    Set objInbox = Nothing
    Set objNS = Nothing

End Sub
Private Sub multiEML2MSG()

Const PR_ICON_INDEX = &H10800003

Dim objPost As Outlook.PostItem
Dim objSafePost As Redemption.SafePostItem
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder


Set objNS = Outlook.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objPost = objInbox.Items.Add(OlItemType.olPostItem)

Set objSafePost = New Redemption.SafePostItem



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

    Set xlObj = New Excel.Application

    Set fd = xlObj.Application.FileDialog(msoFileDialogFolderPicker)
    With fd
        .Title = "Select your PST File"
        .ButtonName = "Ok"
        .Show

        If fd.SelectedItems.Count <> 0 Then
            xDirect$ = fd.SelectedItems(1) & "\"
            xFname$ = Dir(xDirect$, 7)


            licznik = 1
            Do While xFname$ <> ""

            XPathEML = xDirect$ & xFname$
            XPathMSG = Replace(XPathEML, ".eml", ".msg", , , vbTextCompare)
            Debug.Print XPath, Replace(XPath, ".eml", ".msg", , , vbTextCompare)


            objPost.Save
            objSafePost.Item = objPost
            objSafePost.Import XPathEML, Redemption.RedemptionSaveAsType.olRFC822
            objSafePost.MessageClass = "IPM.Note"
            objSafePost.Fields(PR_ICON_INDEX) = none
            objSafePost.SaveAs XPathMSG, Outlook.OlSaveAsType.olMSG



            xFname$ = Dir
            licznik = licznik + 1
        Loop

        End If
    End With

    xlObj.Quit
    Set xlObj = Nothing
    Set objSafePost = Nothing
    Set objPost = Nothing
    Set objInbox = Nothing
    Set objNS = Nothing

End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文