Access-o-Mania

Access-Forum (Deutsch/German) => Access Programmierung => Thema gestartet von: datekk am Mai 11, 2016, 15:42:15

Titel: Bitte um Hilfe bei FileDialog
Beitrag von: datekk am Mai 11, 2016, 15:42:15
Hi,

ich möchte einen FileDialog in meiner Datenbank nutzen. Die Beispiele, welche ich finde, laufen aber alle nicht. Hier das aktuellste:


Private Sub cmdFileDialog_Click()
 
   ' Requires reference to Microsoft Office 11.0 Object Library.

    Dim fDialog As Object
    Set fDialog = CreateObject("Office.FileDialog")
   Dim varFile As Variant
 
   With fDialog

      ' Allow user to make multiple selections in dialog box
      .AllowMultiSelect = True
             
      ' Set the title of the dialog box.
      .Title = "Please select one or more files"

      ' Clear out the current filters, and add our own.
      .Filters.Clear
      .Filters.Add "Access Databases", "*.MDB"
      .Filters.Add "Access Projects", "*.ADP"
      .Filters.Add "All Files", "*.*"

      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
      If .Show = True Then

         'Loop through each file selected and add it to our list box.
         For Each varFile In .SelectedItems
            'Me.FileList.AddItem varFile
         Next

      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With
End Sub


Ausführung bricht wie folgt ab: "Laufzeitfehler 429. Objekterstellung durch Objekt X Komponente nicht möglich."

Folgende Verweise hab ich gesetzt:

- Visual Basic for Application
- Microsoft Access 16.0 Object Library
- OLE Automation
- Microsoft Office 16.0 Access Database engine Object
- Microsoft Outlook 16.0 Object Library
- Microsoft Office 16.0 Object Library

Fragezeichen Fragezeichen Fragezeichen. Bitte um Hilfe. Nutze Office 2016.
Titel: Re: Bitte um Hilfe bei FileDialog
Beitrag von: DF6GL am Mai 11, 2016, 16:36:18
Hallo,


etwa so :

Dim fDialog As Office.Filedialog, varFile As Variant

   Set fDialog = Application.Filedialog(msoFileDialogFilePicker)
   With fDialog
      .AllowMultiSelect = True
      .Title = "Please select one or more files"
 
.
.
.
Titel: Re: Bitte um Hilfe bei FileDialog
Beitrag von: datekk am Mai 16, 2016, 14:45:48
1000 Dank :)