【发布时间】:2020-02-20 00:33:55
【问题描述】:
在我的数据库中,我有一个 VBA 脚本,它打开一个 Excel 电子表格并删除第一行,因此新的第一行是标题行。
当我在 Access VBA 中保存文件并在 Excel 中打开文件时,什么都没有。
如果我重新导入电子表格,数据是可见的。
我更改了我的脚本,如果我不保存更改,文件就可以了。如果我保存更改,则会出现此问题。
dim sheetpath as string
dim xl as excel.application
dim xlbook as excel.workbook
dim xlsheet as excel.worksheet
sheetpath = "c:\users\me\export.xlsx"
set xl = createobject("Excel.Application")
set xlbook = GetObject(sheetpath)
xl.visible = true
set xlsheet = xlbook.Worksheets(1)
If xlsheet.Range("a1").mergecells = true then
xlsheet.cells.unmerge
end if
if xlsheet.range("a1") = "Values" then
xlsheet.rows(1).delete
end if
xlbook.close savechanges:=true
xl.application.qit
set xl = nothing
set xlbook = nothing
set xlsheet = nothing
【问题讨论】: