Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 235
Default Server name in Excel file path

Is it possible to get the full server name in the file path as opposed to
just the drive letter that it refers to?

For example, if I use

ActiveWorkbook.FullName

I get something like this:

L:\test.xls

The full server name for the drive letter L is:

mcssrv02\finserv

I would like the file path to read:

mcssrv02\finserv\test.xls

Thanks for your help.

Kim Mansfield

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Server name in Excel file path

Here's a simple function to get the UNC path

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

Function GetUNCPath(myDriveLetter As String) As String

Dim lReturn As Long
Dim szBuffer As String

myDriveLetter = Left(myDriveLetter, 1) & ":"

szBuffer = String$(256, vbNullChar)
lReturn = WNetGetConnectionA(myDriveLetter, szBuffer, 256)

If lReturn = 0 Then
GetUNCPath = Left$(szBuffer, InStr(szBuffer, vbNullChar))
Else
GetUNCPath = "Invalid drive"
End If

End Function


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"John Mansfield" wrote in message
...
Is it possible to get the full server name in the file path as opposed to
just the drive letter that it refers to?

For example, if I use

ActiveWorkbook.FullName

I get something like this:

L:\test.xls

The full server name for the drive letter L is:

mcssrv02\finserv

I would like the file path to read:

mcssrv02\finserv\test.xls

Thanks for your help.

Kim Mansfield



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default Server name in Excel file path

John,

The full UNC may be exposed through the FSO (FileSystem Scripting Object),
but I'm not certain what method/property it is derived from.
--
http://HelpExcel.com
1-888-INGENIO
1-888-464-3646
x0197758


"John Mansfield" wrote:

Is it possible to get the full server name in the file path as opposed to
just the drive letter that it refers to?

For example, if I use

ActiveWorkbook.FullName

I get something like this:

L:\test.xls

The full server name for the drive letter L is:

mcssrv02\finserv

I would like the file path to read:

mcssrv02\finserv\test.xls

Thanks for your help.

Kim Mansfield

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Server name in Excel file path

http://support.microsoft.com/default...b;en-us;192689
HOWTO: Get UNC Path From a Mapped Network Share's Drive Letter


http://support.microsoft.com/default...b;en-us;160529
VBA: Sample Code to Return the UNC Path of a Network Drive

--
Regards,
Tom Ogilvy

"John Mansfield" wrote in message
...
Is it possible to get the full server name in the file path as opposed to
just the drive letter that it refers to?

For example, if I use

ActiveWorkbook.FullName

I get something like this:

L:\test.xls

The full server name for the drive letter L is:

mcssrv02\finserv

I would like the file path to read:

mcssrv02\finserv\test.xls

Thanks for your help.

Kim Mansfield



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 235
Default Server name in Excel file path

Thanks Bob. I appreciate your help.


"Bob Phillips" wrote:

Here's a simple function to get the UNC path

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

Function GetUNCPath(myDriveLetter As String) As String

Dim lReturn As Long
Dim szBuffer As String

myDriveLetter = Left(myDriveLetter, 1) & ":"

szBuffer = String$(256, vbNullChar)
lReturn = WNetGetConnectionA(myDriveLetter, szBuffer, 256)

If lReturn = 0 Then
GetUNCPath = Left$(szBuffer, InStr(szBuffer, vbNullChar))
Else
GetUNCPath = "Invalid drive"
End If

End Function


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"John Mansfield" wrote in message
...
Is it possible to get the full server name in the file path as opposed to
just the drive letter that it refers to?

For example, if I use

ActiveWorkbook.FullName

I get something like this:

L:\test.xls

The full server name for the drive letter L is:

mcssrv02\finserv

I would like the file path to read:

mcssrv02\finserv\test.xls

Thanks for your help.

Kim Mansfield




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
How do I get the true path to server (not mapped drive letter)? John Excel Worksheet Functions 2 May 18th 06 09:48 PM
Indirect does not recognize full server path? Matt Excel Worksheet Functions 3 January 6th 06 09:18 PM
ChDrive error (server path) Marcotte A Excel Programming 6 November 2nd 05 07:16 PM
How do I use a server name in an Excel chart file path? Zimtok5 Charts and Charting in Excel 1 October 26th 05 02:08 AM


All times are GMT +1. The time now is 11:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"