|
Sub ExportField(strTableName As String,strPath as string)
Dim myxl As Object
Dim rs As New ADODB.Recordset
Dim n As Integer
rs.Open "select top 1 * from " & strTableName, CurrentProject.Connection
Set myxl = CreateObject("excel.application")
myxl.Visible = True
myxl.workbooks.Add
With myxl.activeworkbook.activesheet
For n = 1 To rs.Fields.Count
.cells(, n) = rs.Fields(n - 1).Name
Next
End With
myxl.activeworkbook.saveas strpath & "11.xls"
End Sub
Sub test()
Call ExportField("workbom","c:\huangyz\")
End Sub |
|