troubleshooting Question

The User Would Like to Select Multiple PDF Files at Once from The File Dialog Box

Avatar of gdunn59
gdunn59 asked on
Microsoft AccessVBAPDF
7 Comments1 Solution111 ViewsLast Modified:
I have the following VBA Code that allows the user to select 1 file at a time from the File Dialog Box.

The user would like to select more than one file at a time from the File Dialog Box.

How can that be done?

I have the AllowMultiSelect = True, but I need to know how to get it to work with selecting more than 1 file at a time.

Function AddFile() As LongPtr
  On Error GoTo ErrHandler
  Dim strFilePath As String
  Dim strFileText As String
  Dim strFileName As String
  
  With Application.FileDialog(msoFileDialogOpen)
       .AllowMultiSelect = True
       .Filters.Clear
       .Filters.Add "PDFs", "*.PDF"
       .Show
       strFilePath = .SelectedItems(1)
  End With
  
  If strFilePath = "" Then Exit Function
  
  If GetRecordCount("SELECT * FROM FILE_LIST WHERE FILE_PATH =" & Chr(34) & strFilePath & Chr(34)) > 0 Then
    err.Raise -666, , "This File is Already Loaded!"
  End If

  strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
  strFileText = GetFileText(strFilePath)

  AddFile = AddToFileList(strFilePath, strFileName, strFileText)
  If AddFile <> 0 Then Exit Function
  Me.lstFiles.Requery
  
  Me.lblFileList.Caption = GetRecordCount("FILE_LIST") & " Files"
  Me.lstFiles = Me.lstFiles.ItemData(Me.lstFiles.ListCount - 1) 'should always be at least one
  Call lstFiles_AfterUpdate

  Me.cmdParseBMPs.Enabled = True
 
ErrHandler:
  DoCmd.SetWarnings True
  AddFile = ErrorHandler(err, "AddFile")
End Function

Thanks,
gdunn59
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros