AW: Kompletten Pfad ohne LW Buchstabe
27.02.2007 15:12:00
Rudi
Hallo,
das klappt aber nur bei richtigen Netzlaufwerken:
Private Declare Function WNetGetConnection Lib "mpr.dll" _
Alias "WNetGetConnectionA" (ByVal lpszLocalName _
As String, ByVal lpszRemoteName As String, _
cbRemoteName As Long) As Long
Public Function GetUNCName(ByVal Path As String) As String
Dim UNC As String * 512
If Len(Path) = 1 Then Path = Path & ":"
If Right$(Path, 1) <> "\" Then Path = Path & "\"
If WNetGetConnection(Left$(Path, 2), UNC, Len(UNC)) Then
MsgBox "Es trat ein Fehler auf oder Sie haben versucht eine lokal gespeicherte _
Datei einzubinden!"
Else
GetUNCName = Left$(UNC, InStr(UNC, vbNullChar) - 1) & Mid$(Path, 3)
End If
End Function
Sub test()
MsgBox GetUNCName(ThisWorkbook.Path) & "\" & ThisWorkbook.Name
End Sub
Gruß
Rudi
Eine Kuh macht Muh, viele Kühe machen Mühe