标题: 从ACCESS导入EXCEL问题 [打印本页] 作者: cangqiong 时间: 2007-8-23 16:34 标题: 从ACCESS导入EXCEL问题 首先,在EXCEL里有个表叫A1, 我想ACCESS代码中写,把EXCEL的A1复制一下,名字叫B1,然后把B1更名为当前月份.
但有个问题,在重复执行后,系统会说是否覆盖,然后就退出来了. 请这解决这个问题应该怎么写代码啊?
我想到的是,在执行前把那个当前月份的表删除,然后在执行下一步?
这个代码怎么写啊? 或者有没有更好的方法?作者: andymark 时间: 2007-8-23 18:52
Dim TableName As String
Dim StrExcelName As String
Dim StrFilename As String
Dim obj As AccessObject, dbs As Object
帮我看一下我的代码哪错了
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")))作者: andymark 时间: 2007-8-24 08:28
把例子传上来作者: andymark 时间: 2007-8-24 08:32
DoCmd.DeleteObject acTable, zpname 是删除ACCESS里的表不是EXCEL的SHEET作者: cangqiong 时间: 2007-8-24 09:10
我想删除一个sheet表.....那怎么改啊作者: cangqiong 时间: 2007-8-24 09:52
我传一个例子..帮帮我 解压后把EXCEL文件放在D盘根目录 ACCESS文件随便放到哪
在窗体上点导出按钮