Converting long filenames to short 
Author Message
 Converting long filenames to short

Hi,

In one of my VB5.0 projects I want to control an instance of Excel 5.0
by means of OLE Automation, and open and save spreadsheets there. Am I
right in assuming that I can only deal with short (DOS-based) filenames
when doing so, and if so, is there a simple way to convert long Win95
filenames to the DOS counterparts in VB 5.0?

Thanks,
Frank W Mortensen
Oslo, Norway



Fri, 28 Jan 2000 03:00:00 GMT  
 Converting long filenames to short


->Hi,
->
->In one of my VB5.0 projects I want to control an instance of Excel
5.0
->by means of OLE Automation, and open and save spreadsheets there. Am
I
->right in assuming that I can only deal with short (DOS-based)
filenames
->when doing so, and if so, is there a simple way to convert long
Win95
->filenames to the DOS counterparts in VB 5.0?
->

Here is a snippet of code that should work for you:

Private Declare Function GetShortPathName Lib "kernel32" Alias
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath
As String, ByVal cchBuffer As Long) As Long

Function GetShorty(sFileName As String)

Dim lpShortFileName As String
Dim lSize As Long
Dim lSucc As Long

lpShortFileName = Space$(128)
lSize = Len(lpShortFileName)

'* Fetch the short file name
lSucc = GetShortPathName(sFileName, lpShortFileName, lSize)
'* Discard the trailing spaces and null character.
GetShorty = Left$(lpShortFileName, lSucc)

End Function

Private Sub Form_Load()

Debug.Print GetShorty("c:\Windows\Favorites\SoftCircuits Home
Page.url")

End Sub

Paul
~~~~



Mon, 31 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Convert long filenames to short filenames

2. Convert Long Filenames to Short Filenames in VB4 16-Bit

3. Converting long filenames to short filenames in VB4.0 16-bit

4. NEW: Converting long filenames to short

5. Converting a Long FIleName to it's short equivalent (Both possible shorts)

6. Converting a Long Filename to Short.?

7. converting long filename paths to short

8. SHORT filename to LONG filename???

9. Short Filename to Long Filename ???

10. Long Filename -> Short Filename

11. SHORT filename to LONG filename???

12. Short filename to long filename

 

 
Powered by phpBB® Forum Software