Avatar billede falster Ekspert
14. juni 2004 - 09:40 Der er 3 kommentarer og
1 løsning

VBA - FileDialog object - Outlook 2002 - mappedialogboks

Så vidt jeg kan forstå understøtter Outlook 2002 ikke FileDialog object. Eller måske metoden "Application.FileDialog(msoFileDialogFolderPicker)". (Win2000, Office 2002). Nedenstående kode (stort set kopieret fra VBA-hjælpen) åbner fint en "mappedialog" til filsystemet, d.v.s. en Gennemseboks, i f.eks. Excel eller Word, men ikke i Outlook. Findes der en måde til Outlook?

Sub Main()

    'Declare a variable as a FileDialog object.
    Dim fd As FileDialog

    'Create a FileDialog object as a Folder Picker dialog box.
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)

    'Declare a variable to contain the path
    'of each selected item. Even though the path is a String,
    'the variable must be a Variant because For Each...Next
    'routines only work with Variants and Objects.
    Dim vrtSelectedItem As Variant

    'Use a With...End With block to reference the FileDialog object.
    With fd

        'Use the Show method to display the File Picker dialog box and return the user's action.
        'The user pressed the action button.
        If .Show = -1 Then

            'Step through each string in the FileDialogSelectedItems collection.
            For Each vrtSelectedItem In .SelectedItems

                'vrtSelectedItem is a String that contains the path of each selected item.
                'You can use any file I/O functions that you want to work with this path.
                'This example simply displays the path in a message box.
                MsgBox "The path is: " & vrtSelectedItem

            Next vrtSelectedItem
        'The user pressed Cancel.
        Else
        End If
    End With

    'Set the object variable to Nothing.
    Set fd = Nothing

End Sub
Avatar billede terry Ekspert
14. juni 2004 - 18:17 #1
Avatar billede falster Ekspert
15. juni 2004 - 09:30 #2
Thanks. Yesterday I found an explanation and a work around jusing the Word object:
http://www.outlookcode.com/codedetail.aspx?id=294
It works but seems to be rather slow (due to the opening and closing of Word I guess).

By a quick try out, Your solution comes up with the same Run Time Error '438' as the msoFileDialogFolderPicker: "Object doesn't support this property or method."
Avatar billede terry Ekspert
15. juni 2004 - 09:48 #3
Strange that it isnt supported in Outlook, and I'm surprised that using an API doesnt work eather. There must be a good explanation for it I supposed.
Yes it will be open/close of Word which slows things down I guess, and I dont think there will be so much you can do about that :o(
Avatar billede falster Ekspert
21. juni 2004 - 12:04 #4
Lukker.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester