我有以下的代码是工作,但.close关闭WB不保存行:VBA:Workbooks.Save和关闭不保存
Option Explicit
Public Function updateStatus(fpath As String, fname As String, num As String)
Dim wk As String, yr As String
Dim owb As Workbook
Dim trow As Variant
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False
End With
Set owb = Application.Workbooks.Open(fpath & fname)
trow = owb.Sheets(1).Range("Change" & num).Row
owb.Sheets(1).Cells(trow, 5).value = "Test"
With owb
.Save
.Close SaveChanges:=True 'This line doesn't seem to work
End With
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With
End Function
如果我删除行,世行保持打开状态,我看到变化。如果我添加该行并打开特定文件,则看不到变化。
远程'与应用程序'行在子的顶部(注释掉),看看是否显示警告。 – FunThomas
如果我删除了行,没有任何警告 – PhilHar