Browse for folder

M

MD

In Jim Rech's code for "Browse for Folder", he idicates that we can
establish our own initial folder. If I use a folder that is located on a
newwork and give it the full path \\ MyNetwok\MyFolder \ it does not seem to
work in the old SHELL32.dll format. For it to work I have to map the drive.
This means that ALL the computers in our office need to be maped!!!

We don't use the new format of the SHELL32.dll because it doesn't show the
file unless you expend the tree (unless I don't know how to do it right!).
Unlike the old format, you get the files right a way without having to
expend the tree anymore.

We use Office XP on WindowsXP both with the latest updates.

How can I avoid maping with a drive letter and use the old format.... or use
the new format but show the files included in that folder right a way.

Regards,

Michel
 
J

Jim Rech

I'll take your word for it that old Shell functions do not support UNC
paths.

Not necessarily. Have you considered a temporary mapping? See Sub Demo
below.


Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA"
_
(ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal
lpszLocalName As String) As Long

Declare Function WNetCancelConnection Lib "mpr.dll" Alias
"WNetCancelConnectionA" _
(ByVal lpszName As String, ByVal bForce As Long) As Long

Declare Function WNetGetConnection Lib "mpr.dll" _
Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

Declare Function GetDriveTypeA Lib "KERNEL32" _
(ByVal DriveNumber As String) As Integer

Sub Demo()
Dim TempMap As String
TempMap = GetAvailDriveLtr
If TempMap <> "" Then
Connect TempMap & ":", "\\PMA0010F09\SYS1"
MsgBox TempMap & " is available"
''Do Browse using TempMap
DisConnect TempMap & ":"
End If
End Sub

Function GetAvailDriveLtr() As String
Dim DrvCtr As Integer, DrvType As Integer
For DrvCtr = Asc("C") To Asc("Z")
DrvType = GetDriveTypeA(Chr(DrvCtr) & ":\")
If DrvType <> 0 And DrvType < 2 Then
GetAvailDriveLtr = Chr(DrvCtr)
Exit Function
End If
Next
End Function

Sub Connect(sDrive, sService As String)
On Error GoTo Err_Connect
WNetAddConnection sService & Chr(0), "" & Chr(0), sDrive & Chr(0)
Err_Connect:
End Sub

Sub DisConnect(sDrive As String)
On Error GoTo Err_DisConnect
WNetCancelConnection sDrive + Chr(0), 0
Err_DisConnect:
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top