how can i change the Drive

D

dinga@hk

Because the single-letter-mapping of a network drive will
be not be used in my company, thus the method 'ChDrive' is
not functioned in my statment. Will there be any method to
change the drive ?
 
R

Rob Bovey

dinga@hk said:
Because the single-letter-mapping of a network drive will
be not be used in my company, thus the method 'ChDrive' is
not functioned in my statment. Will there be any method to
change the drive ?

I'm not sure I understand what you mean, but if you are looking for a
way to set the current directory to a UNC type path name then this will
work:

Private Declare Function SetCurrentDirectoryA _
Lib "kernel32" (ByVal lpPathName As String) As Long

Sub SetUNCPath()
SetCurrentDirectoryA "\\SERVER\SHARE\"
End Sub

This also works for mapped drives, so you can use it in either case.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
D

dinga@hk

thanks Rob for your prompt reply.

i'd try your statment but it doesn't work.

Make it clear: let's say the current drive is C:\ and
ThisWorkbook.path is located networkdrive
S:\application\..., it is required direct the user to such
path to get a file to open.

Below is the original statement:

....
ChDrive Left(ThisWorkbook.Path, 1)
ChDir ThisWorkbook.Path
filetoopen = Application.GetOpenFilename("Microsoft
Word,*.DOC,Microsoft Excel,*.XLS,Text
File,*.TXT", , "Select a document")
....
 
B

Bob Phillips

What is not working in your code? AFAIK you will have to map to network
drives to access them, thereby assigning a drive letter. This clearly
suffers the problem that computer A may map it to S and computer B to T, but
there is still a drive letter.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top