v_gyku
09-08-2005, 10:48 PM
I have a code which is allowing user to select a workbook in open dialog.
All the sheets in the selected workbook are displayed in a listbox.
How will i get the folder name(COmplete path of the workbook except the workbook name)
Set SheetList = New Collection
FName = Application.GetOpenFileName("Excel Files (*.xls),*.xls")
If FName <> "False" Then
Set Wkb = Workbooks.Open(FileName:=FName)
End If
txtFileLocation = FName
For Each ws In Wkb.Worksheets
SheetList.Add ws.name
Next
Wkb.Close SaveChanges:=False
n = SheetList.Count
For i = 1 To n
UserControl.List1.AddItem SheetList(i)
Next i
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Set SheetList = Nothing
Set ws = Nothing
Set Wkb = Nothing
All the sheets in the selected workbook are displayed in a listbox.
How will i get the folder name(COmplete path of the workbook except the workbook name)
Set SheetList = New Collection
FName = Application.GetOpenFileName("Excel Files (*.xls),*.xls")
If FName <> "False" Then
Set Wkb = Workbooks.Open(FileName:=FName)
End If
txtFileLocation = FName
For Each ws In Wkb.Worksheets
SheetList.Add ws.name
Next
Wkb.Close SaveChanges:=False
n = SheetList.Count
For i = 1 To n
UserControl.List1.AddItem SheetList(i)
Next i
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Set SheetList = Nothing
Set ws = Nothing
Set Wkb = Nothing