訓練
模組
Create formulas to change behaviors in a Power Apps canvas app - Training
Learn how to enhance and customize your Power Apps canvas app using basic formulas.
您可以藉由檢查活頁簿的 Saved 屬性來判斷活頁簿是否已進行變更。 Saved 屬性會根據活頁簿所做的變更,傳回 True 或 False 值。
備註
可以將 Saved 屬性設定為 True 或 False。 本文的「詳細資訊」區段包含示範使用 Saved 屬性的範例巨集。
工作表中的各種條件,例如揮發性函式的存在,可能會影響 Saved 屬性。
Microsoft 提供的程式設計範例僅供說明之用,並不具任何明示或暗示的責任擔保。 這包括 (但不限於) 任何目的之適售性及適用性的暗示責任擔保。 本文假設您熟悉示範的程式設計語言,也熟悉用以建立和偵錯程序的工具。 Microsoft支援工程師可協助說明特定程式的功能,但不會修改這些範例來提供新增的功能或建構程式,以符合您的特定需求。
Sub TestForUnsavedChanges()
If ActiveWorkbook.Saved = False Then
MsgBox "This workbook contains unsaved changes."
End If
End Sub
此巨集會關閉包含範例程式代碼的活頁簿,並將 Saved 屬性設定為 True 來捨棄活頁簿的任何變更:
Sub CloseWithoutChanges()
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub
Sub CloseWithoutChanges()
ThisWorkbook.Close SaveChanges:=False
End Sub
如需如何使用本文範例程式代碼的詳細資訊,請參閱 如何在 Office 2000 中從知識庫文章執行範例程序代碼。
訓練
模組
Create formulas to change behaviors in a Power Apps canvas app - Training
Learn how to enhance and customize your Power Apps canvas app using basic formulas.
文件
Office VBA reference topic
Application.Quit method (Excel)
Office VBA reference topic
Application.DisplayAlerts property (Excel)
Office VBA reference topic