Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MD MD is offline
external usenet poster
 
Posts: 26
Default Browse for folder

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
MD MD is offline
external usenet poster
 
Posts: 26
Default Browse for folder

Well done Jim. Thank you for your tip

Regards,

Michel


"Jim Rech" a écrit dans le message de
...

it does not seem to work in the old SHELL32.dll format.


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

This means that ALL the computers in our office need to be maped!!!


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


--
Jim Rech
Excel MVP




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
Browse button on form for folder path Greshter Excel Discussion (Misc queries) 2 January 12th 06 10:20 PM
Browse For Folder start directory Todd Huttenstine Excel Programming 2 May 12th 04 02:24 PM
Designate a folder as the root of the Browse tree kiwichico Excel Programming 0 October 1st 03 10:16 PM


All times are GMT +1. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"