
02-28-2003, 08:56 AM
|
 |
Mexican Coder
|
|
Join Date: Jun 2002
Location: Monterrey, N.L., Mexico
Posts: 2,793
|
|
VB Program
Why post this question two times ???
Here is one example of using Excel,
add Project/References/Microsoft Excel X.X Object Library
Add a Command button, and 3 text boxes
Code:
Private Sub Command1_Click()
Dim ExcelApp As New Excel.Application
Dim ExcelWB As Excel.Workbook
Dim ExcelWS As Excel.Worksheet
On Error GoTo ExcelErr
Set ExcelApp = GetObject(, "Excel.Application")
ExcelApp.Visible = True
Set ExcelWB = ExcelApp.Workbooks.Open("C:\Excel.xls")
Set ExcelWS = ExcelWB.Worksheets(1)
ExcelWS.Cells(1, 1) = Text1.Text
ExcelWS.Cells(2, 1) = Text2.Text
ExcelWS.Cells(3, 1) = Text3.Text
Exit Sub
ExcelErr:
Select Case Err.Number
Case 429 ' ActiveX Object not found
Set ExcelApp = CreateObject("Excel.Application")
Resume Next
Case Else 'Other Errors
'Error Stuff here
End Select
End Sub
|
__________________
Mikecrosoft.NET
* If I stop to ask I will stop to learn
* Just I know that I don't know nothing
|