|
-
Jul 15th, 2015, 12:33 PM
#1
Thread Starter
New Member
Combobox issue
i am trying to get a Drop-down Combo-box to open an excel file, just can't seen to get it to work, what do i need in the button1 Click to make my selected Excel file open..
thanks for any help
<Code>
Option Explicit
'do declare these variables you need to add a reference
'to the microsoft excel 'xx' object library.
Dim xl As New Excel.Application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As Excel.Workbook
Private Sub Combo_Change()
'don 't forget to do this or you'll not be able to open
'book1.xls again, untill you restart you pc.
xl.close
End Sub
Private Sub Command_Click(Index As Integer)
End
End Sub
Private Sub Command1_Click(Index As Integer)
Dim Combo As Combobox
Dim xl As New Excel.Application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As Excel.Workbook
'Close excel or reboot PC
xl.Quit
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set xlwbook = xl.Workbooks.Open ' value Selected in Combo should open "need help here"
'strSelect = ComboBox1.Value
'Workbooks.Open FileName:=strSelect
End Sub
Private Sub Form_Load()
'Files in folder listed in Listbox1
Dim FSO As Object, fld As Object, Fil As Object
Dim SubFolderName As String
Dim i As Integer
Set FSO = CreateObject("Scripting.FileSystemObject")
Me.Combo.Clear 'clear previous entries
SubFolderName = "C:\REPORTS"
Set fld = FSO.GetFolder(SubFolderName)
For Each Fil In fld.Files
i = i + 1
Me.Combo.AddItem Fil.Name
Next Fil
'----------------------------- ListBox Filling Content from a directory--------------------------------------
'Files in folder listed in Listbox1
' Dim FSO As Object, fld As Object, Fil As Object
' Dim SubFolderName As String
' Dim i As Integer
'Set FSO = CreateObject("Scripting.FileSystemObject")
'Me.Listbox1.Clear 'clear previous entries
'SubFolderName = "C:\"
'Set fld = FSO.GetFolder(SubFolderName)
'For Each Fil In fld.Files
' i = i + 1
' Me.Listbox1.AddItem Fil.Name
'Next Fil
End Sub
</code>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|