v_gyku
09-06-2005, 12:52 AM
I have a form in which there is a button browse.... on click of which file open dialog window should be opened for selecting excel workbook.Once the excel workbook is selected then that workbookname should me displayed in the textbox and all the names of spreadsheets in that workbook will be displayed in a listbox.
Folowing code is for selecting a access databse . I want to select excel workbook. as soon as the workbook is selected all the respective sheeet names should be displayed in a list box.
Private Sub CmdBrowse_Click()
Dim i As Integer
Dim mypath As String
Dim multiselect As Boolean
If IsAppOpen("Access", "Application") Then
MsgBox "Please close all Access applications"
Exit Sub
End If
'Set the multiselect files value - only one file can be chosen
multiselect = True
filetype = "Access database"
FileFilter = "Access databases" & Chr(0) & "*.mdb*" & Chr(0)
fileArray = GetFilesBrowse(objBrowseButton:=CmdBrowse, _
objFileList:=txtFileLocation, _
strFileType:=filetype, _
strFileFilter:=FileFilter)
List1.Enabled = True
Dim strFormName As Access.Form
Dim file As String
If txtFileLocation.Text = "" Then
Exit Sub
End If
file = Right(txtFileLocation.Text, Len(txtFileLocation.Text) - InStrRev(txtFileLocation.Text, "\"))
ShowAccessforms myDatabase:=filenames, myList:=List1, myFileLocation:=txtFileLocation
End Sub
Folowing code is for selecting a access databse . I want to select excel workbook. as soon as the workbook is selected all the respective sheeet names should be displayed in a list box.
Private Sub CmdBrowse_Click()
Dim i As Integer
Dim mypath As String
Dim multiselect As Boolean
If IsAppOpen("Access", "Application") Then
MsgBox "Please close all Access applications"
Exit Sub
End If
'Set the multiselect files value - only one file can be chosen
multiselect = True
filetype = "Access database"
FileFilter = "Access databases" & Chr(0) & "*.mdb*" & Chr(0)
fileArray = GetFilesBrowse(objBrowseButton:=CmdBrowse, _
objFileList:=txtFileLocation, _
strFileType:=filetype, _
strFileFilter:=FileFilter)
List1.Enabled = True
Dim strFormName As Access.Form
Dim file As String
If txtFileLocation.Text = "" Then
Exit Sub
End If
file = Right(txtFileLocation.Text, Len(txtFileLocation.Text) - InStrRev(txtFileLocation.Text, "\"))
ShowAccessforms myDatabase:=filenames, myList:=List1, myFileLocation:=txtFileLocation
End Sub