Minggu, 15 Oktober 2017

RE: [MS_AccessPros] Copy a file from listbox to folder

 

Hi Art

Check out the VBA FileCopy statement:

https://msdn.microsoft.com/en-gb/vba/language-reference-vba/articles/filecopy-statement

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Monday, 16 October 2017 09:04
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Copy a file from listbox to folder

 

 

I have a list box called lstImports which is populated by a cmdButton called cmdSelectFolder with the following code:

 

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

   Dim fDialog As Office.FileDialog
   Dim varFile As Variant
   ' Clear listbox contents.
   Me.lstImport.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 "PDF Files", "*.Pdf"
      .Filters.add "Word Files", "*.Doc*"
      .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.lstImport.AddItem varFile
         Next

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

 

This code works fine and it allows the user to pick multiple files. Now I have a command button called cmdImport that when clicked needs to take the selected  files in lstImports and copy them to the path called gPathName which is set else where in the application.

 

Any Ideas?

 

Art Lorenzini

Sioux Falls,S D

 

 

__._,_.___

Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar