>Function VFP2Excel > Lparameters tcDataSource, tcSQL, toRange > Local loConn As AdoDB.Connection, ; > loRS As AdoDB.Recordset,; > ix > loConn = Createobject("Adodb.connection") > loConn.ConnectionString = "Provider=VFPOLEDB;Data Source="+m.tcDataSource > loConn.Open() > loRS = loConn.Execute(m.tcSQL) > > For ix=1 To loRS.Fields.Count > toRange.Offset(0,m.ix-1).Value = Proper(loRS.Fields(m.ix-1).Name) > toRange.Offset(0,m.ix-1).Font.Bold = .T. > Endfor > toRange.Offset(1,0).CopyFromRecordSet( loRS ) > loRS.Close > loConn.Close > >Endfunc >What a familiar code. You can then use this alternative:
* Author: Cetin Basoz Function VFP2Excel Lparameters tcDataSource, tcSQL, toRange toRange.Parent.QueryTables.Add(; "OLEDB;Provider=VFPOLEDB;Data Source="+m.tcDataSource, m.toRange, m.tcSQL).Refresh EndfuncCetin