Outlook的保存FileDialog在哪里?

时间:2009-04-28 16:25:10

标签: outlook office-2007 outlook-2007 outlook-addin

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

5 个答案:

答案 0 :(得分:1)

Microsoft Common Dialog

如果您安装了COMDLG32.OCX(“通用对话框ActiveX控件”),那么您可以使用它 - 这里将通过示例进行说明。 (向下滚动屏幕截图,标题为“图2:不要尝试在Word中选择多个文件!”)。

答案 1 :(得分:1)

Outlook的Application对象似乎不提供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

答案 2 :(得分:0)

'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

答案 3 :(得分:0)

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

答案 4 :(得分:0)

var expect = require('chai').expect;
var Promise = require("bluebird");
var sinon = require("sinon");
var AWSMock = require('aws-sdk-mock');

describe.only("Logging tests", function () {

        it.only("Test AWS firehose API invoked", function (done) {

            let mylogger = Logger.getLogger({class: "Unit Test"});
            let firehoseInstance = mylogger.getFirehoseInstance();

            // want to have a callback function that returns a thenable object and not just an object. Not sure how to use it though with mock
            // so for now this is just code that shows what i intend to do.
            let callBackFunc = function( err, recordId) {
                    console.log("debug: returend from putRecord, recordId = " + JSON.stringify(recordId));
                    return Promise.resolve(recordId);
                };

            // calling mock as per the documentation at https://github.com/dwyl/aws-sdk-mock
            AWSMock.mock('Firehose', 'putRecord', function(params, callback) {
                console.log("debug: callback to putRecord to be called");                
                callback(null, {"RecordId": "12345"} );
            });

            // calling a method that should call firehose logging but our mock should intercept it - though it doesn't.
            mylogger.logInfo({ prop1: "value1" }, function(){
                console.log("debug: in the callback that was passed to logInfo...");
                done();
            });

        });
});