hi i'm trying to get the PathCompactPath API to work, but not knowing much about API's i can't track down the problem... the following code is in a userform with 1 label and 1 command button: Private Declare Function PathCompactPath Lib "shlwapi" Alias "PathCompactPathA" (ByVal hDC As Long, ByVal lpszPath As String, ByVal dx As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Option Explicit Private Sub CommandButton1_Click() Me.Label1.Caption = PathCompactPath(GetDC(0), "C:\Program Files\Temp\Temp\Temp\Temp\Temp\Temp\", 198) End Sub any help would be great cheers mark
If you're trying to compact the path, you're using the wrong function Mark. Use this - just paste into a form and watch out for word wrapping: Private Declare Function PathCompactPathEx Lib "shlwapi.dll" Alias _ "PathCompactPathExA" (ByVal pszOut As String, ByVal pszSrc As String, _ ByVal cchMax As Long, ByVal dwFlags As Long) As Long Private Sub CommandButton1_Click() Dim sSave As String 'buffer sSave = String(255, 0) 'truncate a path to fit within 20 characters by 'replacing path components with ellipses. PathCompactPathEx sSave, "C:\This\is\a\long\path\myfile.txt", 20, 0 'show the result TextBox1.Text = StripTerminator(sSave) End Sub Function StripTerminator(sInput As String) As String Dim ZeroPos As Long ZeroPos = InStr(1, sInput, Chr(0)) If ZeroPos > 0 Then StripTerminator = Left(sInput, ZeroPos - 1) Else StripTerminator = sInput End If End Function -- Mike ___________________________ Mike Tuersley CADalyst's CAD Clinic Rand IMAGINiT Technologies ___________________________ the trick is to realize that there is no spoon...