Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preselect network folder with GetOpenFilename

Status
Not open for further replies.

tbl

Technical User
May 15, 2001
175
BE
I would like to preselect the folder that GetOpenFilename uses.
if a drive has been created I know that I can use ChDir and ChDrive, but the folder that I need is on a network and has the path "\\server\folder"
I want to just let the users select a file and not open it

Any help would be much appreciated

Richard
 
You could use a shell command to map the netwerkdrive first and then use that:

Code:
Sub Map_NetworkDrive()

    Const NETWORKDRIVE As String * 1 = "G"
    Const SERVERNAME As String = "SomeServer"
    Const FOLDERPATH As String = "FolderName[\FolderName\..]"
    
    Shell "net use " & NETWORKDRIVE & ": /d"
    Shell "net use " & NETWORKDRIVE & ": \\" & SERVERNAME & "\" & FOLDERPATH
        
    Do
        On Error Resume Next
        Err.Clear
        ChDrive NETWORKDRIVE
    Loop Until Err.Number = 0
    
    ChDir NETWORKDRIVE & ":\"
    Application.GetOpenFilename

End Sub

the Do Loop is necessary because the shell works asynchronously, so you need to wait for the mapping to be completed. You might want to introduce a timer to abort the loop after some seconds in case the drive cannot be mapped.

Cheers,

Roel
 
Thanks a lot, will try that

Richard
 
Have a look at my suggestion here:
thread707-1470461

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top