ينطبق على
Access لـ Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

ينطبق على

عنصر Application

يُرجع عنصر FileDialog الذي يمثل مثيلاً واحداً لمربع حوار ملف.

expression.FileDialog‏(dialogType)

expression Required. هو تعبير يقوم بإرجاع أحد العناصر الموجودة في القائمة "ينطبق على".

نوع الحوار    مطلوب MsoFileDialogType . نوع مربع حوار ملف.

يمكن أن يكون MsoFileDialogType واحداً من ثوابت MsoFileDialogType هذه.

msoFileDialogFilePicker

msoFileDialogFolderPicker

msoFileDialogOpen غير مدعوم في Microsoft Access.

msoFileDialogSaveAs غير مدعوم في Microsoft Access.

ملاحظات

لا يتم دعم ثوابت msoFileDialogOpenوmsoFileDialogSaveAs في Access.

مثال

يوضح هذا المثال كيفية استخدام عنصر FileDialog لعرض مربع حوار يسمح للمستخدم بتحديد ملف واحد أو أكثر. تتم إضافة الملفات المحددة بعد لك إلى مربع قائمة يسمى FileList.

Private Sub cmdFileDialog_Click()
   ' Requires reference to Microsoft Office 11.0 Object Library.
   Dim fDialog As Office.FileDialog
   Dim varFile As Variant
   ' Clear listbox contents.
   Me.FileList.RowSource = ""
   ' Set up the File Dialog.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   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", "*.ACCDB"
      .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

هل تحتاج إلى مزيد من المساعدة؟

الخروج من الخيارات إضافية؟

استكشف مزايا الاشتراك، واستعرض الدورات التدريبية، وتعرف على كيفية تأمين جهازك، والمزيد.