File Dialog Permission denied error on redirected folders (1 Viewer)

Minty

AWF VIP
Local time
Today, 11:45
Joined
Jul 26, 2013
Messages
10,368
Hi All,

I have a file dialog I use to get the location of various files for importing (shown below).
I have an issue with a client who uses file redirection at a corporate level and keeps getting an error - Error 70 Permission Denied.

In my testing, if I set strInitialDir to anything that doesn't exist or a totally bobbins file location it simply reverts to the last place explorer was opened to. But not on their machines. My guess is that because the file path exists, but for some reason the file dialog can't get to it I get the error. Testing this is proving awkward as you can imagine.

I've tried capturing the error and resetting the initial dir to "" but that doesn't seem to work.

Anyone got any ideas?

Code:
Public Function strGetFileFolderName(Optional strInitialDir As String = "", Optional lngType As Long = 4, Optional strPattern As String = "All Files,*.*") As String
    'StrInitialDir = where the filedialog starts browsing
    'lngType e.g. 'msoFileDialogFilePicker = 3, msoFileDialogFolderPicker =4, msoFileDialogOpen=1,msoFileDialogSaveAs=2

    Dim fDialog     As Object
    Dim vFile       As Variant, varEntry As Variant

    strGetFileFolderName = ""
    
    Set fDialog = Application.FileDialog(lngType)
    
    With fDialog
        .Title = "Browse for "
        Select Case lngType
            Case 1                                'msoFileDialogOpen
                .Title = .Title & "File to open"
            Case 2                                'msoFileDialogSaveAs
                .Title = .Title & "File to SaveAs"
            Case 3                                'msoFileDialogFilePicker
                .Title = .Title & "File"
            Case 4                                'msoFileDialogFolderPicker
                .Title = .Title & "Folder"
        End Select
        
        Select Case strPattern
            Case "Excel"
                strPattern = "MS Excel,*.XLSX; *.XLSM; *.XLS"
            Case "Access"
                strPattern = "MS Access,*.ACCDB"
            Case "PPT"
                strPattern = "MS Powerpoint,*.PPTX; *.PPTM"
        End Select
        
        
        If lngType <> 4 Then
            'Reset then add filter patterns separated by tildes (~) where
            '  multiple extensions are separated by semi-colons (;) and the
            '  description is separated from them by a comma (,).
            '  Example strPattern :
            '  "MS Access,*.ACCDB; *.MDB~MS Excel,*.XLSX; *.XLSM; *.XLS"
            Call .Filters.Clear
            For Each varEntry In Split(strPattern, "~")
                Call .Filters.Add(Description:=Split(varEntry, ",")(0), _
                    Extensions:=Split(varEntry, ",")(1))
            Next varEntry
        End If
        'Set some default settings
        .InitialFileName = strInitialDir
        .AllowMultiSelect = False
        .InitialView = 2                          'msoFileDialogViewDetails
        'Only return a value from the FileDialog if not cancelled.
        If .Show Then strGetFileFolderName = .SelectedItems(1)
        
    End With
    
ExitHere:
    Exit Function
    
HandleErrors:
    MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
    Resume ExitHere
End Function
 

Minty

AWF VIP
Local time
Today, 11:45
Joined
Jul 26, 2013
Messages
10,368
@Ranman256 I have tried that, it doesn't work because it gets redirected.
They don't have direct access to the C:\ drive. Same with their \user\Documents folder.

What I haven't tried is one of the shares they all have mapped though... I think H:\ might work.
Worth a go. I can't test things until tomorrow.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:45
Joined
Feb 28, 2001
Messages
27,140
The test that would eliminate most of the questions about permissions requires you to go to the client machine that exhibits this and manually (via Windows File Explorer) follow that path to get a detailed error message. You would also be able to right-click on the elements of the path in order to determine effective permissions. ( {file >> right-click} >> Properties >> Security >> Effective permissions )
 

Minty

AWF VIP
Local time
Today, 11:45
Joined
Jul 26, 2013
Messages
10,368
Thanks @The_Doc_Man - I think that's what I'm going to have to do tomorrow once some remote access is arranged.
On the brief test I was able to run, when I checked what was returned using special folders (Documents) was simply "\" !

Which should just return you to a default folder.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:45
Joined
Feb 28, 2001
Messages
27,140
This question is also relevant: How are they doing the redirection and at what level?
 

Users who are viewing this thread

Top Bottom