motleyjew
Registered User.
- Local time
- Today, 17:08
- Joined
- Jan 11, 2007
- Messages
- 109
I am trying to get the file path from a linked ole object in my database. I am using code microsofts website. Here is the link to the article. I have listed the code below.
http://support.microsoft.com/kb/199066
I am able to get the code to work, however I am having a problem when a folder or file name is over 8 characters. When a file is over 8 characters it inserts a "~1" after the file name. Here is a example:
Actual File Name
\\FOLDER\Public\Asset Managment\6-10-08.XLS
String generated after function is ran
\\FOLDER\Public\ASSETM~1\6-10-0~1.XLS
Any help would be appreciated.
Gregg
http://support.microsoft.com/kb/199066
I am able to get the code to work, however I am having a problem when a folder or file name is over 8 characters. When a file is over 8 characters it inserts a "~1" after the file name. Here is a example:
Actual File Name
\\FOLDER\Public\Asset Managment\6-10-08.XLS
String generated after function is ran
\\FOLDER\Public\ASSETM~1\6-10-0~1.XLS
Any help would be appreciated.
Gregg
Code:
Function GetLinkedPath(objOLE As Variant) As Variant
Dim strChunk As String
Dim pathStart As Long
Dim pathEnd As Long
Dim path As String
If Not IsNull(objOLE) Then
' Convert string to Unicode.
strChunk = StrConv(objOLE, vbUnicode)
pathStart = InStr(1, strChunk, ":\", 1) - 1
' If mapped drive path not found, try UNC path.
If pathStart <= 0 Then pathStart = _
InStr(1, strChunk, "\\", 1)
' If either drive letter path or UNC path found, determine
' the length of the path by searching for the first null
' character Chr(0) after the path was found.
If pathStart > 0 Then
pathEnd = InStr(pathStart, strChunk, Chr(0), 1)
path = Mid(strChunk, pathStart, pathEnd - pathStart)
GetLinkedPath = path
Exit Function
End If
Else
GetLinkedPath = Null
End If
End Function