there are some ways to open an excel file in vb...
here's what i'd do...
Code:
Dim XLS As Object
Dim XLSheet As Object
Dim intRow As Integer
Dim intCol As Integer
' Initialize the function, assume it's OK
fxnExportData = True
' Set the Application (Excel)
Set XLS = CreateObject("Excel.Application")
' Add a workbook
XLS.Workbooks.Add
' Add a Worksheet
XLS.Worksheets.Add
' Name the worksheet
XLS.ActiveSheet.Name = "MySheetFromVB"
Set XLSheet = XLS.Worksheets("MySheetFromVB")
' You can set the values of individual cells, e.g.
XLSheet.Cells(1, 1) = "Company ID"
XLSheet.Cells(1, 2) = "Employee Number"
XLSheet.Cells(1, 3) = "Dept Code"
XLSheet.Cells(1, 4) = "Salary"
XLSheet.Cells(1, 5) = "Date Hired"
intRow = 2
' You can also use values of controls in your forms... XLSheet.Cells(intRow, 1) = "'" & txtCompany
XLSheet.Cells(intRow, 2) = "'" & txtEmpNo
XLSheet.Cells(intRow, 2) = "'" & txtDeptCode
XLSheet.Cells(intRow, 2) = & txtSalary
XLSheet.Cells(intRow, 3) = txtDateHired
' You can also format from VB
' Format Cells/Columns/Rows
XLSheet.Columns("E:E").NumberFormat = "dd-mm-yyyy"
XLSheet.Rows("1:1").Font.Bold = True
XLSheet.Columns("A:I").EntireColumn.AutoFit
' To save...
XLSheet.SaveAs Filename:="C:\TestDir\MyXLS.xls"
' Close/Save any open Excel File and Quit the Excel Application
XLSheet.Application.Quit
' Release the Excel object variables
Set XLSheet = Nothing
Set XLS = Nothing
hope this helps...
