ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how can i change the Drive (https://www.excelbanter.com/excel-programming/299363-how-can-i-change-drive.html)

dinga@hk

how can i change the Drive
 
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 ?



Rob Bovey

how can i change the Drive
 
"dinga@hk" wrote in message
...
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 *




dinga@hk

how can i change the Drive
 
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")
....

-----Original Message-----
"dinga@hk" wrote in

message
...
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 *



.


Bob Phillips[_6_]

how can i change the Drive
 
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)

"dinga@hk" wrote in message
...
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")
...

-----Original Message-----
"dinga@hk" wrote in

message
...
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 *



.





All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com