I am trying to script the Import Spreadsheet Wizard.
I used the tip here http://www.microsoft.com/technet/scr...7/hey0404.mspx to create an access database from an Excel workbook.
However, this misses out the crucial step at the end where the wizard says "Let Access Add Primary Key"
How do I add the primary key?
At the moment I have a vbs file that looks like this.
Code:Option Explicit Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim Path Path = fso.GetParentFolderName(WScript.ScriptFullName) '* Dim cMDB Dim cXLS cMDB = Path & "\db1.mdb" cXLS = Path & "\myfile.xls" '* Dim objACC Set objACC = CreateObject("Access.Application") objACC.NewCurrentDatabase cMDB objACC.DoCMD.TransferSpreadsheet 0, 8, "java", cXLS, False, "java!" objACC.DoCMD.TransferSpreadsheet 0, 8, "visualb", cXLS, False, "visualb!" objACC.closeCurrentDatabase Set objACC = Nothing




Reply With Quote