Results 1 to 4 of 4

Thread: Solved: openfiledialog run-time error 75 path/file Access Error

  1. #1

    Solved: openfiledialog run-time error 75 path/file Access Error


    I'm trying to copy files selected in the openfiledialog to c:\Rawdata.

    The code below causes the Run-time error 75.

    Public Sub GetFiles()
    Dim fDialog As Office.FileDialog
    Dim fso As New FileSystemObject
    Dim Path As String
    Dim Filename As String
    Dim varFile As Variant
    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

    With fDialog
    .AllowMultiSelect = True
    .Title = "Please select one or more files"
    .Filters.Add "CSM Files", "*.TXT"
    Path = "C:\RawData"

    If .Show = True Then
    For Each varFile In .SelectedItems
    Filename = varFile
    FileCopy varFile, Path
    MsgBox "You clicked Cancel in the file dialog box."
    End If
    End With
    End Sub

    From what i've read on-line the error relates to permisions or lack of source file. The file clearly exists and I can copy and paste the file to the destination directory from within the open file dialog window so I can't see a permissions issue. I'm very new to VBA, and I'm probably missing something that should be obvious.

    Any advice much appreciated

  2. #2
    VBAX Mentor
    Feb 2009
    The FileCopy command expects a file name as the destination, but you're giving it a folder instead.

    In this example from my system, the first command triggers that same error #75. The second works without error.
    [VBA]FileCopy "C:\Access\wip\temp.bas", "C:\Access"
    FileCopy "C:\Access\wip\temp.bas", "C:\Access\temp.bas"

  3. #3
    Thankyou very much Hansup.

    As I'm sellecting 4 files in the dialog box it sounds like I'll
    need to strip off the filename from the Source string, store it as a var
    and append it to the Destination path something like

    FileCopy "C:\TestData\Test.txt", "C:\Rawdata\" & Filename

    I'll give this a try.

    Many thanks

  4. #4
    Hansup, This works perfectly. You've just washed away hours of frustration :-)

    Thankyou very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts