<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PathCompactPath trouble in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158756#M49091</link>
    <description>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 &amp;gt; 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...</description>
    <pubDate>Thu, 14 Oct 2004 15:54:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2004-10-14T15:54:47Z</dc:date>
    <item>
      <title>PathCompactPath trouble</title>
      <link>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158755#M49090</link>
      <description>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</description>
      <pubDate>Thu, 14 Oct 2004 06:53:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158755#M49090</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-14T06:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: PathCompactPath trouble</title>
      <link>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158756#M49091</link>
      <description>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 &amp;gt; 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...</description>
      <pubDate>Thu, 14 Oct 2004 15:54:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158756#M49091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-14T15:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: PathCompactPath trouble</title>
      <link>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158757#M49092</link>
      <description>thanks mike, just what i needed

cheers

mark


"Mike Tuersley" &lt;MTUERSLEY&gt; wrote in message
news:l6cx6l8dy1fs.m23e1b2tr2r9$.dlg@40tude.net...
&amp;gt; If you're trying to compact the path, you're using the wrong function
Mark.
&amp;gt; Use this - just paste into a form and watch out for word wrapping:
&amp;gt;
&amp;gt; Private Declare Function PathCompactPathEx Lib "shlwapi.dll" Alias _
&amp;gt; "PathCompactPathExA" (ByVal pszOut As String, ByVal pszSrc As String, _
&amp;gt; ByVal cchMax As Long, ByVal dwFlags As Long) As Long
&amp;gt;
&amp;gt; Private Sub CommandButton1_Click()
&amp;gt;   Dim sSave As String
&amp;gt;   'buffer
&amp;gt;   sSave = String(255, 0)
&amp;gt;   'truncate a path to fit within 20 characters by
&amp;gt;   'replacing path components with ellipses.
&amp;gt;   PathCompactPathEx sSave, "C:\This\is\a\long\path\myfile.txt", 20, 0
&amp;gt;   'show the result
&amp;gt;   TextBox1.Text = StripTerminator(sSave)
&amp;gt; End Sub
&amp;gt;
&amp;gt; Function StripTerminator(sInput As String) As String
&amp;gt;   Dim ZeroPos As Long
&amp;gt;   ZeroPos = InStr(1, sInput, Chr(0))
&amp;gt;   If ZeroPos &amp;gt; 0 Then
&amp;gt;     StripTerminator = Left(sInput, ZeroPos - 1)
&amp;gt;   Else
&amp;gt;     StripTerminator = sInput
&amp;gt;   End If
&amp;gt; End Function
&amp;gt;
&amp;gt;
&amp;gt; -- Mike
&amp;gt; ___________________________
&amp;gt; Mike Tuersley
&amp;gt; CADalyst's CAD Clinic
&amp;gt; Rand IMAGINiT Technologies
&amp;gt; ___________________________
&amp;gt; the trick is to realize that there is no spoon...&lt;/MTUERSLEY&gt;</description>
      <pubDate>Thu, 14 Oct 2004 22:15:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/pathcompactpath-trouble/m-p/1158757#M49092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-10-14T22:15:48Z</dc:date>
    </item>
  </channel>
</rss>

