Hi,
I've got 2 methods for you:
Solution 1
Just code for VB or Vba, try this(object method):
Dim objExcel As Object
Set objExcel = CreateObject("Excel.application")
objExcel.Visible = True 'if you want to see excel during the program
objExcel.Workbooks.open "....."
.....
objExcel.ActiveWorkbook.SaveAs "g:\tmp\test.xls"
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objExcel = Nothing
REMARK: if you run excel on the background and there is crash, you sometimes have to close the excel with the CTRL+DEL option(taskmanager)
Solution 2
First you have to select the Microsoft Excel (9.0) Object Library in the Project-reference menu
Then you can use some code like below:
Dim OExcel As Excel.Application
Dim OWork As Excel.Workbook
Dim OSheet As Excel.Worksheet
Set OExcel = Excel.Application
Set OWork = OExcel.Workbooks.Add
Set OSheet = OWork.Worksheets.Add
Osheet.Name = "test"
Osheet.Cells(1, 1) = "test!"
OWork.SaveAs "g:\tmp\test1.xls"
OWork.Close
OExcel.Quit
Set OWork = Nothing
Set OExcel = Nothing
Set OSheet = Nothing
This is the method I used the first time, now I'm using the object method.
Your choice.
Gollem