getting letter of mapped network drive

getting letter of mapped network drive

Anonymous
Not applicable
221 Views
2 Replies
Message 1 of 3

getting letter of mapped network drive

Anonymous
Not applicable
I've written a program that saves my drawing to two different directories.
one of the directories is on my local hard drive; the other is a mapped
network drive (a folder on the network). The drive letter on my machine is
"J". Trouble is, i'd like to let my co-workers use this program, but their
mapped network drive letter is different (one is "K", one is "F", etc.).
How can I use VBA to find out this drive letter and assign it to a variable?
Thanks...

Brian
0 Likes
222 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
One way is to use the Microsoft Scripting Runtime. If you don't have it, you
can get it http://msdn.microsoft.com/scripting. Pass this routine the share
you're looking for and it will return the drive letter that it is mapped to
(assuming it exists)

Public Function GetDriveByShare(share As String) As String

Dim fso As FileSystemObject, drv As Drive

Set fso = New FileSystemObject
For Each drv In fso.Drives
If drv.ShareName = share Then
GetDriveByShare = drv.DriveLetter
Exit For
End If
Next

End Function

--
Visit me at: http://www2.stonemedia.com/franko

"Brian Mears" wrote in message
news:[email protected]...
> I've written a program that saves my drawing to two different directories.
> one of the directories is on my local hard drive; the other is a mapped
> network drive (a folder on the network). The drive letter on my machine
is
> "J". Trouble is, i'd like to let my co-workers use this program, but
their
> mapped network drive letter is different (one is "K", one is "F", etc.).
> How can I use VBA to find out this drive letter and assign it to a
variable?
> Thanks...
>
> Brian
>
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
I would point to the absolute referencing rather than your relative
referencing (i.e., f:, or g:, or h:, etc.)

For example "\\local_network_drive\accessed_directory\subdirectory"

you can find what this is by looking through explorer by selecting the drive
you wish to write to.

Eric

Brian Mears wrote in message
news:[email protected]...
> I've written a program that saves my drawing to two different directories.
> one of the directories is on my local hard drive; the other is a mapped
> network drive (a folder on the network). The drive letter on my machine
is
> "J". Trouble is, i'd like to let my co-workers use this program, but
their
> mapped network drive letter is different (one is "K", one is "F", etc.).
> How can I use VBA to find out this drive letter and assign it to a
variable?
> Thanks...
>
> Brian
>
>
0 Likes