VB 打开已有excel、修改、保存,出错提示“该文件已存在,是否要覆盖” 源代码如下,如何解决?

2025-01-20 02:51:32
推荐回答(1个)
回答1:

dim ex as object
Set ex = CreateObject("Excel.Application")
ex.Visible = False
Dim fname As String
fname = "d:\大宋银行.xls"
ex.Workbooks.Open (fname)
ex.cells(1, 1) = "顾客"
ex.cells(1, 2) = "金额"
.....
把你的 xlsheet都改为ex
....
ex.DisplayAlerts = False '关闭提示
ex.ActiveWorkbook.SaveAs( "d:\大宋银行.xls")
ex.Quit
Set ex = Nothing