PDA

View Full Version : Application.FileDialog(msoFileDialogFolderPicker) with Network Folder Path



Cinema
09-26-2018, 07:06 AM
I am trying to select a folder in the following network folder path:

\\serverX.zmi@SSL\DavWWWRo (file://\\serverX.zmi@SSL\DavWWWRo)ot\TestDocument\001_Test


ActiveWorkbook.FollowHyperlink Address:="\\serverX (file://serverx.zmi@ssl/DavWWWRo).zmi@SSL\DavWWWRoot\TestDocument\001_Test", NewWindow:=True opens the folder in windows explorer view.

How to combine this with my actual code:


Set foDialog = Application.FileDialog(msoFileDialogFolderPicker)
With foDialog
.Title = "Select a Folder
.AllowMultiSelect = False
.InitialFileName = :="\\serverX (file://serverx.zmi@ssl/DavWWWRo).zmi@SSL\DavWWWRoot\TestDocument\001_Test"

If .Show = -1 Then
fsFilePath = .SelectedItems(1)
Else
fsFilePath = ""
End If
End With

End Sub



It cannot open the network folder

Kenneth Hobs
09-26-2018, 11:22 AM
.InitialFileName = "\\serverX (file://serverx.zmi%40ssl/DavWWWRo).zmi@SSL\DavWWWRoot\TestDocument\001_Test"

Cinema
09-26-2018, 12:52 PM
Hi Kenneth thank you for replying. There is a typo in the code.sorry. The solution you suggested, which is also my try, doesnt work. It opens an https view in windows explorer.

Cinema
09-26-2018, 12:54 PM
There is a typo. It should be:
.InitialFileName = "\\serverX.zmi@SSL\DavWWWRoot\TestDocument\001_Test"

Kenneth Hobs
09-26-2018, 01:11 PM
This is weird. I guess you could try using a virtual drive. I can show you how if needed.

Normally, I add a backslash character at the end.

.InitialFileName = "\\serverX.zmi@SSL\DavWWWRoot\TestDocument\001_Test\"


Sub test_GetFolder()
MsgBox Get_Folder(ThisWorkbook.path & "\", "Folder Picker")
End Sub

Function Get_Folder(Optional FolderPath As String, _
Optional HeaderMsg As String) As String
With Application.FileDialog(msoFileDialogFolderPicker)
If FolderPath = "" Then
.initialFilename = Application.DefaultFilePath
Else
.initialFilename = FolderPath
End If
.Title = HeaderMsg
If .show = -1 Then
Get_Folder = .SelectedItems(1)
Else
Get_Folder = ""
End If
End With
End Function

Paul_Hossler
09-26-2018, 01:45 PM
This little snippet will open the dialog on a folder on a PC on the home network




Option Explicit
Sub test()
Dim foDialog As FileDialog
Dim fsFilepath As String
Set foDialog = Application.FileDialog(msoFileDialogFolderPicker)

With foDialog
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = "\\denpc2\Q\Media Server\Movies"

If .Show = -1 Then
fsFilepath = .SelectedItems(1)
Else
fsFilepath = ""
End If
End With

End Sub




Are you sure this is the server name? -- the dot and at sign seem unusual (to me anyway)

Also, possible that the at and/or the dot might not be compatible with
msoFileDialogFolderPicker ??




.InitialFileName = :="
\\serverX (file://serverx.zmi@ssl/DavWWWRo)
.zmi@SSL\DavWWWRoot\TestDocument\001_Test"

Cinema
09-27-2018, 02:09 AM
Hi thank you both for replying. The codes still open an https://adress. Maybe this is the reason:
My Shrepoint has not the permission to open Sharepoint with explorer. This button is deactivated. So everytime I want to pick a folder from the generated network folder it switches to the https view.

Is that a possible reason ? Is there no way to circumvent this ?

Paul_Hossler
09-27-2018, 07:46 AM
If this is on a Sharepoint server, you didn't mention it

That requires a different approach as I recall

I don't have access to a Sharepoint server, but see if this technique works, assuming that you have all the required permissions to the server

Again, it's only using a non-SharePoint drive on my local network





Sub FolderBrowse()

Dim objShell As Object
Dim objFolder As Object

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Example", 0, "\\denpc2\Q\Media Server\Movies")

If (Not objFolder Is Nothing) Then

MsgBox objFolder.self.Path

End If

Set objFolder = Nothing
Set objShell = Nothing
End Sub