自从安装Office 2007以来,我们的VBA应用程序代码停止工作。当我调试时,我得到一个编译错误,并且.edit被突出显示。我用.update取代了.edit,我没有得到任何调试错误,但是当我运行代码时,我得到了一个类型不匹配的错误代码。我做错了什么?这里是codez:安装Office 2007后VBA应用程序出现问题
Private Sub Command290_Click()
对错误转到Err_Command290_Click “这个程序导入了最新的Changepoint CSV文件导入的ChangepointCSV表。 'SR:有效的日常
Dim FullFileName As String 'full file path & name
Dim myDB As Database
Dim rstAsOfDate As Recordset
Dim rstCumulativeResources As Recordset
Dim strOldDate As String
Dim tableExists As Integer
Dim strExistingCSVTable As String
Dim transferSuccessful As String
Dim deleteBackup As Boolean
' 设置默认值 一系列mydb = CurrentDb strExistingCSVTable = “ChangepointCSV”
“形式的维护来限制用户选择 DoCmd.Close acForm, “frmMain”,acSaveNo DoCmd.OpenForm “frmImportingCPData”
( “之前设置RS”) '获取现有CSV文件 名' MSGBOX 设置rstAsOfDate = myDB.OpenReco rdset( “tblChangepointFileName”) 'MSGBOX( “后RS集”)
With rstAsOfDate
'MsgBox ("inWITH")
.Edit
'Store original data.
strOldDate = !CurrentFileName
End With
rstAsOfDate.Close
' 获得文件的名称将要导入 FullFileName =的GetFile() “MSGBOX( “DEBUG FullFileName =” + FullFileName)
'FullFileName = "C:Documents and Settings ext.xlsx"
“比较现有的以最新 如果strOldDate = FullFileName然后 MSGBOX “的RI目前包含了最新的Changepoint数据提取。” deleteBackup =假 转到RestoreForms 结束如果
'如果的Changepoint CSV表存在,那么将其备份的情况下的误差的 tableExists = ObjectExists_20%( “表”,strExistingCSVTable)
If tableExists = -1 Then
DoCmd.CopyObject , "ChangepointCSV-backup", acTable, strExistingCSVTable
DoCmd.DeleteObject acTable, strExistingCSVTable
End If
' 传递最新的CSV文件 transferSuccessful = TransferSpreadsheetFile(strExistingCSVTable,FullFileName) 'MsgBox(“DEBUG:Transfer Successful:”+ transferSuccessful)
'如果最新的CSV文件没有被导入,恢复备份CSV并退出, 'else继续处理。
If transferSuccessful = 0 Then
DoCmd.CopyObject , strExistingCSVTable, acTable, "ChangepointCSV-backup"
MsgBox "The Changepoint data could not be refreshed at this time. Please try again later."
deleteBackup = True
GoTo RestoreForms:
Else
'MsgBox ("before RS set")
Set rstAsOfDate = myDB.OpenRecordset("tblChangepointFileName")
'MsgBox ("after RS set")
'Update Filename
With rstAsOfDate
'MsgBox ("inWITH")
.Edit
'Store original data
!CurrentFileName = FullFileName
.Update
End With
rstAsOfDate.Close
'MsgBox ("RS closed")
Set rstCumulativeResources = myDB.OpenRecordset("tbl_CumulativeResources")
Do While Not rstCumulativeResources.EOF
rstCumulativeResources.Delete
rstCumulativeResources.MoveNext
Loop
rstCumulativeResources.Close
DoCmd.RunMacro "mcrFTEAnalysis"
deleteBackup = True
GoTo RestoreForms
End If
“恢复主窗体和清理备份文件 RestoreForms: 如果deleteBackup = TRUE,则 DoCmd.DeleteObject能够作用, “ChangepointCSV的备份” 结束如果
DoCmd.Close acForm, "frmImportingCPData", acSaveNo
'MsgBox ("DEBUG: import form closed")
DoCmd.OpenForm "frmMain", acNormal
Exit_Command290_Click: 退出子
Err_Command290_Click: MSGBOX错误。Description Resume Exit_Command290_Click End Sub
有两种不同的'.Edit'部分在该代码。哪一个被标记为错误? – barrowc 2010-04-23 06:01:54