|
-
Sep 30th, 2008, 09:02 AM
#1
Thread Starter
Junior Member
Excel
Hi -
I need to list an xls file's fields in a listbox 'List1'. The xls is selected from a filelistbox 'File2'.
This is the following code I am using but it keeps on telling me that the filename 'TEMP.XLS' could not be found, although I have checked that the path and filename is correct.
For n1 = 0 To (File2.ListCount - 1) 'Counts the number of xls files
If File2.Selected(n1) = True Then 'Checks if a xls has been selected
dbfsel = File2.List(n1) 'The selected xls
End If
Next
Set DBase = opendatabase ("D:\Erwin_files\My_Data\User_Request\Erwin\DEL_Multiple_fields\Table\TEMP.XLS", False, False, "EXCEL 8.0;")
THE FILE NOT FOUND MSG COMES UP WHEN THIS 'SET' STRING IS EXECUTED
Set rs = DBase.OpenRecordset(dbfsel) 'dbfsel is the selected xls
With rs
For n2 = 0 To rs.Fields.Count - 1
List1.AddItem rs.Fields(n2).Name
Next n2
End With
rs.Close
Thanx in advance
-
Oct 1st, 2008, 03:24 AM
#2
Re: Excel
You have already opened a connection to the excel spreadsheet with this line
vb Code:
Set DBase = opendatabase ("D:\Erwin_files\My_Data\User_Request\Erwin\DEL_Multiple_fields\Table\TEMP.XLS", False, False, "EXCEL 8.0;")
when you are opening a recordset to it you should be passing it the Sheet name or number like "Sheet1"
Set rs = DBase.OpenRecordset("Sheet1")
Please Mark your Thread "Resolved",  if the query is solved & Rate those who have helped you
-
Oct 3rd, 2008, 06:51 AM
#3
Thread Starter
Junior Member
Re: Excel
 Originally Posted by NeedSomeAnswers
You have already opened a connection to the excel spreadsheet with this line
vb Code:
Set DBase = opendatabase ("D:\Erwin_files\My_Data\User_Request\Erwin\DEL_Multiple_fields\Table\TEMP.XLS", False, False, "EXCEL 8.0;")
when you are opening a recordset to it you should be passing it the Sheet name or number like "Sheet1"
Set rs = DBase.OpenRecordset("Sheet1")
Hi -
Thanx for the advise; much appreciated
Regards
Erwin
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
|