|
-
Aug 29th, 2000, 04:56 AM
#1
Thread Starter
New Member
Hello,
Just a quick question. How can I use excel with my VB Application ? I have an excel file but I dont know how to incorporate it with my VB apps. I know how to do it with MS Access but with Excel I can't. May I ask for your suggestions and help on this one, quite need the info.
Thanks in advance.
Paul
-
Aug 29th, 2000, 11:22 AM
#2
Frenzied Member
You can add a reference to Micrsoft Excel #.# Object library and then open an instance of excel in your code:
Global goXLApp As excel.Application
Global goXLBooks as excel.workbook
Set goXLApp = New excel.Application
Set goXLBooks = goXLApp.Workbooks.Open(App.Path & "C:\data\filename.XLS")
'read cell b1 (you'll see why in a minute)
If Mid(CStr(goXLBooks.worksheets(1).Cells(1, 2).Value), 1, 5) = "Error" Then
'note that the column letter gets changed to a number and that you access a cell by row, column
gsMsgBoxMsg = "Unable to read Excel cell B,1. Contact support for help"
form.Cell.Text = "0"
Else
form.cell.Text = Format(goXLBooks.worksheets(1).Cells(1, 2).Value, "###,###,###,###.00")
End If
[Edited by JHausmann on 08-29-2000 at 04:22 PM]
-
Aug 29th, 2000, 11:18 PM
#3
Thread Starter
New Member
Hi,
Thank you very much for your reply. May I ask how would I configure the properties of... say... my textbox if I'm going to use the Excel file? Sorry, quite a beginner at this, as I know if using an Access database you would set the Data Source and Data Field properties of the textbox. Would this be also done?
Thanks again.
-
Aug 30th, 2000, 09:59 AM
#4
Frenzied Member
Except for ADO, you cannot bind the data to a control. It's simple enough to do manually, my first post would place the data from a spreadsheet cell into a field. You simply need to invert it to send the data back to excel.
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
|