ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Circumvent drive mappings, reference network location (https://www.excelbanter.com/excel-programming/377333-circumvent-drive-mappings-reference-network-location.html)

Kathryn208

Circumvent drive mappings, reference network location
 
Can office programs (Excel specifically) to recognize a
network location that DOES NOT include a drive letter?

For example, can Excel link to the datasource:
\\server_name\folder_name\data_source.mdb

Rather than:
P:\folder_name\data_source.mdb





Chip Pearson

Circumvent drive mappings, reference network location
 
In general, yes. The following worked for me

Workbooks.Open "\\DellLaptop\MainDrive\book1.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)


"Kathryn208" wrote in message
...
Can office programs (Excel specifically) to recognize a
network location that DOES NOT include a drive letter?

For example, can Excel link to the datasource:
\\server_name\folder_name\data_source.mdb

Rather than:
P:\folder_name\data_source.mdb







Jim Thomlinson

Circumvent drive mappings, reference network location
 
I have never had an issue with this. I also have this code which will tell
you the server mapping of a local drive letter (for whatever it's worth)...

Option Explicit

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA"
( _
ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, _
ByRef cbRemoteName As Long) As Long

Sub Test()
MsgBox UNCfromLocalDriveName("P")
End Sub

Function UNCfromLocalDriveName(strLocalDrive) As String
'Find UNC from Local path
'i.e. Local drive "F:" = "\\RdaServer3\sys1"
' example of usage: UNCfromLocalDriveName("P") <-Actual Drive Letter
' or UNCfromLocalDriveName(A2) <-Cell reference
'
Dim sLocal As String
Dim sRemote As String * 255
Dim lLen As Long

Application.Volatile

sRemote = String$(255, Chr$(32))

lLen = 255
sLocal = strLocalDrive & ":"

WNetGetConnection sLocal, sRemote, lLen

UNCfromLocalDriveName = Trim(sRemote)

End Function
--
HTH...

Jim Thomlinson


"Kathryn208" wrote:

Can office programs (Excel specifically) to recognize a
network location that DOES NOT include a drive letter?

For example, can Excel link to the datasource:
\\server_name\folder_name\data_source.mdb

Rather than:
P:\folder_name\data_source.mdb






All times are GMT +1. The time now is 01:16 PM.

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