vba excel 运行-time error 438 with .quit
vba excel run-time error 438 with .quit
Run Time Error 438 - Object Doesn't Support this Property or Method.
上周一切正常,这周却出现了错误弹窗。
此外,我还有另一个例程可以很好地处理相同的细节....我不知道为什么
但是我发布代码是想问你一个解决方案
Sub ProcessFiles() Dim Filename, Pathname As String
Dim wb As Workbook
Pathname = "C:\Users\tecnico2\Desktop\revisione prova\"
Filename = Dir(Pathname & "*.xlsm")
Do While Filename <> ""
Set wb = Workbooks.Open(Pathname & Filename)
DoWork wb
wb.Save
wb.Quit '<-------------- **the error appears here-**----------
Filename = Dir()
Loop
End Sub
Sub DoWork(wb As Workbook)
With wb
Call AddDBFasi
End With
End Sub
取决于你想做什么:
您想关闭工作簿吗?然后是wb.close
(如果你用wb.Close True
,它会保存工作簿,你可以去掉wb.Save
)。
您想完全关闭 Excel 吗?使用 Application.Quit
Run Time Error 438 - Object Doesn't Support this Property or Method.
上周一切正常,这周却出现了错误弹窗。
此外,我还有另一个例程可以很好地处理相同的细节....我不知道为什么
但是我发布代码是想问你一个解决方案
Sub ProcessFiles() Dim Filename, Pathname As String
Dim wb As Workbook
Pathname = "C:\Users\tecnico2\Desktop\revisione prova\"
Filename = Dir(Pathname & "*.xlsm")
Do While Filename <> ""
Set wb = Workbooks.Open(Pathname & Filename)
DoWork wb
wb.Save
wb.Quit '<-------------- **the error appears here-**----------
Filename = Dir()
Loop
End Sub
Sub DoWork(wb As Workbook)
With wb
Call AddDBFasi
End With
End Sub
取决于你想做什么:
您想关闭工作簿吗?然后是wb.close
(如果你用wb.Close True
,它会保存工作簿,你可以去掉wb.Save
)。
您想完全关闭 Excel 吗?使用 Application.Quit