Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jleiker
Starting Member
13 Posts |
Posted - 2004-10-21 : 09:08:20
|
Please help?! We just upgraded from 97 to 2003 version. This is a scheduler routine which auto imports an excel spreadsheet into our main db. After I upgraded it stops on with "compile error variable not defined" Also after the conversion ...there was an error that said "May be due to old DAO syntax that is no longer supported" l am pasting the module code below but this line is where I get the error:FileFormat:=xlexcel9795, Password:="", WriteResPassword:="", _This is password protected database now...didn't used to be. It was inherited and have no idea of what to do.I don't have any idea of what to do and this has to run every night.CODE:Public Function importisfile(imptype As String)Dim importpath As String 'path for work or homeDim impfile As String 'filename of xl importDim tempfile As String 'temporary for rewriteDim tblimptemp As String 'tablenameDim stdocname As String 'conversion stringDim stdocname1 As String 'conversion stringDim recsetname As StringDim XL As ObjectDim db As Database 'used in traversalDim rec As Recordset 'used in traversalDim tbltempstr As String 'table to traverseDim x As Integer 'used to count traversal'importpath = "V:\Administration\Imports\"importpath = "V:\Administration\Imports\"impfile = importpath + "TOX" + "kit.xls" 'eg. c:\import\TOXCANkit.xlstempfile = importpath + "TOX" + "kit2.xls" 'eg. c:\import\TOXUSkit2.xlsstdocname = "qryappendimportTOX" 'date conversion in this querystdocname1 = "qrydeleteimportTOX" 'date conversion in this querytblimptemp = "tblimporttempTOX" + "Kit" 'eg. tblimporttempTOXCANKittbltempstr = "tblTOX" + "kit"On Error GoTo Err_imp1Set XL = CreateObject("Excel.Application")With XL.Application.Visible = True.Workbooks.Open impfile.ActiveWorkbook.SaveAs FileName:=tempfile, _FileFormat:=xlexcel9795, Password:="", WriteResPassword:="", _ReadOnlyRecommended:=False, CreateBackup:=False.QuitEnd WithSet XL = NothingKill impfileName tempfile As impfile'transfers the readable xls file into access databaseDoCmd.TransferSpreadsheet (acImport), acSpreadsheetTypeExcel97, tblimptemp, impfile |
|
K_Mueller
Starting Member
3 Posts |
Posted - 2004-11-02 : 03:39:30
|
Hallo,replace:Dim db As Database 'used in traversalDim rec As Recordset 'used in traversalwith:Dim db As DAO.Database 'used in traversalDim rec As DAO.Recordset 'used in traversaland set a reference to the DAO Object LibraryKlaus |
 |
|
jleiker
Starting Member
13 Posts |
Posted - 2004-11-05 : 08:06:47
|
I did set the reference and that fixed it (excel object reference). Do you think I still need to replace the other code you suggested since it's working now? Thanks so much for your reply! |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-11-05 : 09:05:21
|
in Access versions > 97, if you just the DAO object library, ALWAYS prefix DAO objects with "DAO" to avoid confusion and because it is no longer the default library and ADO has many of the same object names.- Jeff |
 |
|
|
|
|
|
|