I have this code in my VB 6 app, no References to Excel (I use late binding):
Code:
Option Explicit
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Private Sub cmdShow_Click()
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.ActiveSheet
On Error GoTo ErrH
recOne.Open txtSQL.Text, Cn
With xlApp
For i = 0 To recOne.Fields.Count - 1
.Sheets(1).Cells(1, i + 1) = recOne.Fields(i).Name
Next
.Sheets(1).Range("A2").CopyFromRecordset recOne
For i = 1 To recOne.Fields.Count
.Sheets(1).Columns(i).EntireColumn.AutoFit
Next
.Visible = True
End With
recOne.Close
End Sub
But when I want to Save it, Excel wants to Save the file as Book1.xls, but it is Excel 2010 and it should save it as Book1.xls[red]x[/red]
What do I need to do for Excel to recognize the 2010 version and by default save files as xlsx?
Have fun.
---- Andy