Article ID: 139402
Article Last Modified on 10/11/2006
Sub CreateXLS()
Dim Db as Database
Dim Tbl as TableDef
Dim Fld as Field
'Create and open an Excel 5.0 database
Set Db = OpenDatabase("C:\Test\Book1.xls", False, False, "Excel 5.0;")
'Create a new table definition for a table called NewTable
Set Tbl = Db.CreateTableDef("NewTable")
'Create a new field in NewTable and call it NewField
Set Fld = tbl.CreateField("NewField", dbInteger)
'Append the field to the table and then append the table to the
'database
Tbl.Fields.Append Fld
Db.TableDefs.Append Tbl
'Close the database
Db.Close
End Sub
After you run this macro, a Microsoft Excel 5.0 workbook called Book1.xls
will reside in the directory C:\Test. This workbook will contain one
worksheet called "NewTable" and also a defined name called "NewTable" which
refers to the range NewTable!$A$1:$A$1. Cell A1 will contain the text
"NewField."
Additional query words: 8.00 97 XL97 XL7 XL
Keywords: kbdtacode kbhowto kbprogramming KB139402