標題:
(感謝大大們協助完成)如何排除~當程式建立於~開啟時寫入~每次關閉都會問是否要儲存
[打印本頁]
作者:
av8d
時間:
2012-6-28 21:57
標題:
(感謝大大們協助完成)如何排除~當程式建立於~開啟時寫入~每次關閉都會問是否要儲存
本帖最後由 av8d 於 2012-6-29 16:17 編輯
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each Sh In Sheets
If Sh.Name <> "Index" Then Sh.Visible = False
End Sub
Private Sub Workbook_Open()
Sheets("Index").Select
For i = 1 To 4
ActiveSheet.OLEObjects("CommandButton" & i).Visible = False
Next
ActiveSheet.OLEObjects("Textbox1").Activate
End Sub
當程式建立於~開啟時寫入~每次關閉都會問是否要儲存~是否可以讓他自動判斷~或是其他方法?
作者:
kimbal
時間:
2012-6-28 22:59
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim result
If ThisWorkbook.Saved = False Then
result = MsgBox("""" & ThisWorkbook.Name & """ 此檔案已被修改,是否要儲存?", vbYesNoCancel)
End If
If result = vbYes Then
For Each Sh In Sheets
If Sh.Name <> "Index" Then Sh.Visible = False
Next
ThisWorkbook.Save
Exit Sub
ElseIf result = vbNo Then
ThisWorkbook.Saved = True
ElseIf result = vbCancel Then
Cancel = True
Exit Sub
End If
End Sub
WORKBOOK_OPEN後 的狀態設成已儲存
Private Sub Workbook_Open()
Sheets("Index").Select
For i = 1 To 4
ActiveSheet.OLEObjects("CommandButton" & i).Visible = False
Next
ActiveSheet.OLEObjects("Textbox1").Activate
thisworkbook.saved=true
End Sub
複製代碼
關時自動存
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each Sh In Sheets
If Sh.Name <> "Index" Then Sh.Visible = False
thisworkbook.save
End Sub
複製代碼
作者:
hugh0620
時間:
2012-6-29 09:04
其實會詢問你要不要儲存~ 這是有需要的~
有些時候在修改了某些資料時~ 有可能改錯~
若是不excel詢問的話~ 有可能會導致整個資料無法被救回來~
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)