Welcome to the Forums.
What version of Excel are you using? Do you need to support different versions of Excel?
This will work.
Moved from Classic VB forum.VB Code:
Option Explicit Private Sub Command1_Click() Dim oApp As Object Dim oWB As Object Dim oSht As Object Set oApp = CreateObject("Excel.Application") oApp.Visible = True Set oWB = oApp.Workbooks.Add Set oSht = oWB.Sheets("Sheet1") oSht.Cells(1, 1).Value = "This is column A, row 1" oWB.Close SaveChanges:=True, FileName:="C:\Book1.xls" Set oSht = Nothing Set oWB = Nothing oApp.Quit Set oApp = Nothing End Sub





Reply With Quote