ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Network path in cell (https://www.excelbanter.com/excel-programming/427187-network-path-cell.html)

K[_2_]

Network path in cell
 
Hi all, The Macro below put path in cell A1 which is "F:\Documents
\Data
\Record.xlsx"

Sub getpath()
Range("A1").Value = ThisWorkbook.FullName
End Sub


I work in office and we save everything on network drive. The above
file or path is actually in "\\Home\Trader\Documents\Data
\Record.xlsx". Please can any friend can help that how can I make
appear network path instead of drive path in cell A1. I tried code
below to achive what i want but there must be some way in excel vba
to
get network path by code.


Sub getpath()
Range("A1").Value = "\\Home\Trader" & Right(ThisWorkbook.FullName,
Len
(ThisWorkbook.FullName) - 2)
End Sub



Patrick Molloy[_2_]

Network path in cell
 
the issue here is that its the O/S that maps the drive to the network path.
It spossible that users may not have the same mapping.

You could do this with a call to a Windows API - but its non-trivial...and
not my area of competence either. sorry




"K" wrote:

Hi all, The Macro below put path in cell A1 which is "F:\Documents
\Data
\Record.xlsx"

Sub getpath()
Range("A1").Value = ThisWorkbook.FullName
End Sub


I work in office and we save everything on network drive. The above
file or path is actually in "\\Home\Trader\Documents\Data
\Record.xlsx". Please can any friend can help that how can I make
appear network path instead of drive path in cell A1. I tried code
below to achive what i want but there must be some way in excel vba
to
get network path by code.


Sub getpath()
Range("A1").Value = "\\Home\Trader" & Right(ThisWorkbook.FullName,
Len
(ThisWorkbook.FullName) - 2)
End Sub




Dave Peterson

Network path in cell
 
Randy Birch shows how using API calls.

http://vbnet.mvps.org/index.html?cod...appeddrive.htm



K wrote:

Hi all, The Macro below put path in cell A1 which is "F:\Documents
\Data
\Record.xlsx"

Sub getpath()
Range("A1").Value = ThisWorkbook.FullName
End Sub

I work in office and we save everything on network drive. The above
file or path is actually in "\\Home\Trader\Documents\Data
\Record.xlsx". Please can any friend can help that how can I make
appear network path instead of drive path in cell A1. I tried code
below to achive what i want but there must be some way in excel vba
to
get network path by code.

Sub getpath()
Range("A1").Value = "\\Home\Trader" & Right(ThisWorkbook.FullName,
Len
(ThisWorkbook.FullName) - 2)
End Sub


--

Dave Peterson

Patrick Molloy[_2_]

Network path in cell
 
Excellent! I knew I'd seen it somewhere.

and the link opens to the exact code needed too :)

WNetGetConnection: Get UNC Path for Mapped Drive

best regards
Patrick

"Dave Peterson" wrote:

Randy Birch shows how using API calls.

http://vbnet.mvps.org/index.html?cod...appeddrive.htm



K wrote:

Hi all, The Macro below put path in cell A1 which is "F:\Documents
\Data
\Record.xlsx"

Sub getpath()
Range("A1").Value = ThisWorkbook.FullName
End Sub

I work in office and we save everything on network drive. The above
file or path is actually in "\\Home\Trader\Documents\Data
\Record.xlsx". Please can any friend can help that how can I make
appear network path instead of drive path in cell A1. I tried code
below to achive what i want but there must be some way in excel vba
to
get network path by code.

Sub getpath()
Range("A1").Value = "\\Home\Trader" & Right(ThisWorkbook.FullName,
Len
(ThisWorkbook.FullName) - 2)
End Sub


--

Dave Peterson



All times are GMT +1. The time now is 01:48 AM.

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