Avatar billede dta Nybegynder
08. juli 2004 - 16:29 Der er 5 kommentarer og
1 løsning

Vælg fil

Jeg har brug for en routine i Access der kan vælge en fil i filstrukturen. Den skal helst bruge den samme opbygning som standard objected brugt i Windows! Ingen objecter må bruges. Filnavnet skal returneres med fuld sti!
Avatar billede ricky Nybegynder
08. juli 2004 - 16:57 #1
In order to display a file dialog box using the FileDialog object, you must use the Show method. Once a dialog box is displayed, no code will execute until the user dismisses the dialog box. The following example creates and displays a File Picker dialog box and then displays each selected file in a message box.

Sub Main()

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

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

    '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
08. juli 2004 - 17:30 #2
Prøv evt at se det eks, som jeg har liggende her: http://www.makeiteasy.dk/eksempler/Downloads.htm

Ekspemplet hedder Åbn Fil-dialogboksen...
Avatar billede terry Ekspert
08. juli 2004 - 19:49 #3
"Ingen objecter må bruges" ?
Then how is it possible to >
"bruge den samme opbygning som standard objected brugt i Windows" ?
09. juli 2004 - 08:59 #4
Terry, jeg tror bare, at han mener, at han ikke vil bruge Active X-komponenter eller andre eksterne komponenter.
Har jeg ret, dta?
09. juli 2004 - 09:14 #5
Ricky-> FileDialog er ikke standard i Access. Ved du hvilken reference, man skal sætte?
Avatar billede dta Nybegynder
09. juli 2004 - 10:52 #6
Lige efter bogen tak!
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
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

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