|
3#
楼主 |
发表于 2007-8-24 08:25:55
|
只看该作者
DoCmd.DeleteObject acTable, TableName
这句运行错误
帮我看一下我的代码哪错了
Dim EX As Excel.Application
Dim rs As Recordset
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim str As String
Dim i As Integer
Dim Returnvalue
Dim temp, XH, XH1 As Integer
Dim zpname, zpname1 As String
Dim Temptable As Excel.Worksheet
str = 取得路径() & "\学校"
Set wb = Workbooks.Open("" & str & "")
Set ws = wb.Worksheets("一部")
'Windows.Application.Visible = True
'------------------------------------------------------------------------------------
zpname = "一部" & CStr(Format(Date, "YYYY-MM"))
For Each Temptable In Worksheets
If Temptable.Name = zpname Then
temp = MsgBox(zpname & "已经存在,是否重新生成", vbYesNo)
If temp = vbYes Then
DoCmd.DeleteObject acTable, zpname ' 这句运行错误
End If
If temp = vbNo Then
MsgBox "不能创建同样名称的表,关闭工作簿"
wb.Save
wb.Close
Set rs = Nothing
Set ws = Nothing
Set wb = Nothing
Exit Sub
End If
End If
Next
ws.Copy before:=Sheets(Sheets.Count)
Sheets(Sheets.Count - 1).Name = "一部" & CStr(Format(Date, "YYYY-MM"))
Set ws = wb.Worksheets("一部" & CStr(Format(Date, "YYYY-MM"))) |
|