Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Identify the network path a file was opened from (Excel2007)

Not sure if I am using the correct keywords/tricky phrases here but...
I have a workbook placed on our network that contains a macro other can use
create a standard report. I want to write into the code, a way to confirm
that they are using the network file (most current) and not a copy they
placed on their CPU. I have tried the whole path, GetDrive, etc. methods but
it only gives me the "mapped name" (ex1: "T:\") and not the actual network
path information (ex2: "\\usatx\stdrpts\E&Ocalc\"). Hope this makes sense,
any ideas how to get to this level of information in example 2 or other
method to confirm they are using the correct file?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Identify the network path a file was opened from (Excel2007)

I googled for some help and found this:
http://www.xtremevbtalk.com/showthread.php?t=146146

I tried this, but I can't test it because I'm not on a network.

Option Explicit
Private Const UNIVERSAL_NAME_INFO_LEVEL As Long = &H1

Private Type UNIVERSAL_NAME_INFO
lpUniversalName As String * 256
End Type

Private Declare Function WNetGetUniversalName Lib "mpr" _
Alias "WNetGetUniversalNameA" _
(ByVal lpLocalPath As String, _
ByVal dwInfoLevel As Long, _
lpBuffer As Any, _
lpBufferSize As Long) As Long

Sub Auto_Open()

Dim lngResults As Long
Dim udtUNCPath As UNIVERSAL_NAME_INFO
Dim myStr As String

myStr = ThisWorkbook.Path

If Mid(myStr, 2, 2) = ":\" Then
'looks like a mapped drive x:\xxxx\xxxx
lngResults = WNetGetUniversalName(Left(myStr, 3), _
UNIVERSAL_NAME_INFO_LEVEL, udtUNCPath, Len(udtUNCPath))
MsgBox Replace(udtUNCPath.lpUniversalName, vbNullChar, "")
Else
MsgBox myStr
End If

End Sub

If it doesn't work, you can try googling for "UNC Mapped VB API" and get lots of
hits.

DataBoy wrote:

Not sure if I am using the correct keywords/tricky phrases here but...
I have a workbook placed on our network that contains a macro other can use
create a standard report. I want to write into the code, a way to confirm
that they are using the network file (most current) and not a copy they
placed on their CPU. I have tried the whole path, GetDrive, etc. methods but
it only gives me the "mapped name" (ex1: "T:\") and not the actual network
path information (ex2: "\\usatx\stdrpts\E&Ocalc\"). Hope this makes sense,
any ideas how to get to this level of information in example 2 or other
method to confirm they are using the correct file?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Identify the network path a file was opened from (Excel2007)

On Sep 24, 4:35*pm, Dave Peterson wrote:
I googled for some help and found this:http://www.xtremevbtalk.com/showthread.php?t=146146

I tried this, but I can't test it because I'm not on anetwork.

Option Explicit
Private Const UNIVERSAL_NAME_INFO_LEVEL As Long = &H1

Private Type UNIVERSAL_NAME_INFO
* * lpUniversalName As String * 256
End Type

Private Declare Function WNetGetUniversalName Lib "mpr" _
* *Alias "WNetGetUniversalNameA" _
* * (ByVal lpLocalPath As String, _
* * *ByVal dwInfoLevel As Long, _
* * *lpBuffer As Any, _
* * *lpBufferSize As Long) As Long

Sub Auto_Open()

* * Dim lngResults As Long
* * Dim udtUNCPath As UNIVERSAL_NAME_INFO
* * Dim myStr As String

* * myStr = ThisWorkbook.Path

* * If Mid(myStr, 2, 2) = ":\" Then
* * * * 'looks like a mapped drive x:\xxxx\xxxx
* * * * lngResults = WNetGetUniversalName(Left(myStr, 3), _
* * * * * * * * * * * UNIVERSAL_NAME_INFO_LEVEL, udtUNCPath, Len(udtUNCPath))
* * * * MsgBox Replace(udtUNCPath.lpUniversalName, vbNullChar, "")
* * Else
* * * * MsgBox myStr
* * End If

End Sub

If it doesn't work, you can try googling for "UNC Mapped VB API" and get lots of
hits.

DataBoy wrote:

Not sure if I am using the correct keywords/tricky phrases here but...
I have a workbook placed on ournetworkthat contains a macro other can use
create a standard report. I want to write into the code, a way to confirm
that they are using thenetworkfile (most current) and not a copy they
placed on their CPU. I have tried the wholepath, GetDrive, etc. methods but
it only gives me the "mapped name" (ex1: "T:\") and not the actualnetwork
pathinformation (ex2: "\\usatx\stdrpts\E&Ocalc\"). Hope this makes sense,
any ideas how to get to this level of information in example 2 or other
method to confirm they are using the correct file?


--

Dave Peterson


Excellent... it works great... and the additional search criteria
information was very helpful; it always about using the correct works
in the search to get to the right information (I would rate this a 5
out of 5 stars if the link the system provided in the reply email
worked), Thank you!
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
Format cells to pick up the name of the person who opened the excel in a network Dileep Chandran Excel Worksheet Functions 0 November 7th 06 06:58 AM
Path to a network drive CWillis Excel Discussion (Misc queries) 2 June 23rd 06 03:06 AM
Can't open excel on network drive, it said somebody has opened it soe soe Excel Discussion (Misc queries) 1 December 1st 05 01:02 PM
file opened twice on network stevenmorrison Excel Discussion (Misc queries) 1 October 25th 05 03:44 PM


All times are GMT +1. The time now is 03:10 AM.

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

About Us

"It's about Microsoft Excel"