我有一個Excel工作表,我需要設置截止日期上,這樣當出現將過期的文件變得毫無用處,他們必須聯繫我獲得該文件的新版本。使用Excel到期的工作表
我寫了強制要顯示的第一個工作表和隱藏工作表兩(其中包含日期),如果沒有啓用宏和片材讀取宏必須能夠繼續腳本。一旦它們啓用宏表,表格2變得可見並且它們可以利用這些數據。一旦宏啓用腳本運行的到期日的命令,並且當前日期已過有效期限顯示一個消息窗口警告用戶他們的文件過期。問題是,在此消息窗口關閉後,excel會提示用戶保存,不保存或取消。如果用戶選擇取消,則顯示的下一個消息框是到期日期窗口,並且過期日期報告他們有負日子。然後,他們可以關閉該窗口並訪問計算器。
我已經涉足與「ActiveWorkbook.Save = TRUE」之下,但沒有avial功能。
Private Sub Workbook_BeforeClose(Cancel As Boolean) ActiveWorkbook.Saved = True End Sub
它禁用我的工作表,要求用戶啓用宏,這是一個沒有去,基本上呈現文件沒用。
我重視的VBA腳本,希望你們能幫忙。
非常感謝!
下面是代碼:
Private Const dsWarningSheet As String = "sheet1" 'Enter name of the Entry/Warning Page
私人小組Workbook_BeforeSave(BYVAL SaveAsUI由於布爾,取消由於布爾)
For Each ds In ActiveWorkbook.Sheets
If LCase(dsWarningSheet) = LCase(ds.Name) Then
ds.Visible = True
End If
Next
結束子
私人小組Workbook_Open()
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional
Dim Edate As Date
On Error Resume Next
myCount = Application.Sheets.Count
For i = 2 To myCount
Sheets(i).Visible = True
If i = myCount Then
Sheets(1).Visible = xlVeryHidden
End If
Next i
Edate = Format("13/01/2012", "DD/MM/YYYY") ' Replace this with the date you want
If Date > Edate Then
MsgBox ("This worksheet was valid upto " & Format(Edate, "dd-mmm-yyyy") & " and will be closed: Please contact John Smith at Company ABC to purchase a new version of this calculator")
ActiveWorkbook.Close
End If
If Edate - Date < 30 Then
MsgBox ("This worksheet expires on " & Format(Edate, "dd-mmm-yyyy") & " You have " & Edate - Date & " Days left")
End If
結束子
私人小組Workbook_BeforeClose(取消由於布爾)
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional
On Error Resume Next
myCount = Application.Sheets.Count
Sheets(1).Visible = True
Range("A1").Select
For i = 2 To myCount
Sheets(i).Visible = xlVeryHidden
If i = myCount Then
End If
Next i
ActiveWorkbook.Save
結束子
私人小組Workbook_Openxx()
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional
On Error Resume Next
myCount = Application.Sheets.Count
For i = 2 To myCount
Sheets(i).Visible = True
If i = myCount Then
Sheets(1).Visible = xlVeryHidden
End If
Next i
結束子