K
Kou Vang
I have dumped the Active X for the API Common Dialog. I want however the
result of the selection of the Dialog to be a variant. I can select the
files from the Dialog, but am unable to add them to my lstbox. Any help
would be great! Thanks!
Function LaunchCD(strform As Form) As Variant
Dim V As Variant
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "Excel Files (*.xls)" & Chr(0) & "*.xls"
'"JPEG Files (*.JPG)" & Chr(0) & "*.JPG" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "n:\trafmon\vc_data\newtube"
OpenFile.lpstrTitle = "Select a file using the Common Dialog DLL"
OpenFile.flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
LaunchCD = V
End Function
Private Sub Command2_Click()
Dim I As Integer
Dim V As Variant
Dim Fname As String
Dim F
V = LaunchCD(Me)
If Not IsEmpty(V) Then
For I = 0 To UBound(V)
Fname = StrReverse(Split(StrReverse(V(I)), "\", 2)(0))
Debug.Print Fname
Text1.AddItem F
Debug.Print F
Next I
End If
End Sub
result of the selection of the Dialog to be a variant. I can select the
files from the Dialog, but am unable to add them to my lstbox. Any help
would be great! Thanks!
Function LaunchCD(strform As Form) As Variant
Dim V As Variant
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "Excel Files (*.xls)" & Chr(0) & "*.xls"
'"JPEG Files (*.JPG)" & Chr(0) & "*.JPG" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "n:\trafmon\vc_data\newtube"
OpenFile.lpstrTitle = "Select a file using the Common Dialog DLL"
OpenFile.flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
LaunchCD = V
End Function
Private Sub Command2_Click()
Dim I As Integer
Dim V As Variant
Dim Fname As String
Dim F
V = LaunchCD(Me)
If Not IsEmpty(V) Then
For I = 0 To UBound(V)
Fname = StrReverse(Split(StrReverse(V(I)), "\", 2)(0))
Debug.Print Fname
Text1.AddItem F
Debug.Print F
Next I
End If
End Sub