Well here's what I'd do...
Break up each directory seperately. Something like this (I'm coding it now so I hope there aren't errors):
Dim sPath as string
Dim sTemp as string
Dim sNewPath as String
Dim sExt as string
sNewPath = left(sPath,3)
sPath = right(sPath,len(sPath)-3) 'Gets rid of root. i.e. "C:\"
Do until instr(1,sPath,"\",1) = 0
sTemp = left(sPath,instr(1,sPath,"\",1)-1)
sPath = right(sPath,len(sPath)-len(sTemp)-1)
If len(sTemp) > 8 Then
sTemp = left(sTemp,6) & "~1"
End If
sNewPath = sNewPath & sTemp & "\"
Loop
'Now, sPath should just be your file name
sExt = right(sPath,4) 'as long as the extension is 3 characters
sPath = left(sPath,len(sPath)-len(sExt))
If len(sPath) > 8 then
sPath = left(sPath,6) & "~1"
End IF
sNewPath = sNewPath & sPath & sExt
I hope that works for you. The only way this won't work is if two directorys or filenames have the same first six characters and you are trying to access the second one. Anyway, good luck.
Enter your message below
Sign in or Join us (it's free).