|
发表于 2024-5-29 12:30
来自手机
|
显示全部楼层
micch 发表于 2024-5-29 11:23
这种就没任何意义了,主要目的是看代码,学习如何设计,不是白嫖成品。
文件设了密码,还做了混淆 ...
试试AI吧,足够强大
Private WithEvents App As Application
Attribute App.VB_VarHelpID = -1
Private IsPickerVisible As Boolean
Private Sub Class_Initialize()
On Error Resume Next
Set App = Application
IsPickerVisible = False
On Error GoTo 0
End Sub
Private Sub Class_Terminate()
ResetState
End Sub
Public Property Get PickerVisible() As Variant
PickerVisible = IsPickerVisible
End Property
Public Property Let PickerVisible(ByVal NewValue As Variant)
IsPickerVisible = NewValue
End Property
Private Sub HidePickerAndCleanup()
ResetState
PerformCleanupActions
End Sub
Private Sub ShowPicker()
HidePickerAndCleanup
End Sub
Private Sub ResetState()
IsPickerVisible = False
End Sub
Private Sub PerformCleanupActions()
ResetState
If ShouldPerformCleanupActions() Then
PerformActualCleanup
End If
End Sub
Private Function ShouldPerformCleanupActions() As Boolean
On Error GoTo check_err
Dim cellAbove As Range
ShouldPerformCleanupActions = False
If (ShouldCheckForCleanup) Then
If TypeName(ActiveCell) = "Range" Then
If VBA.IsDate(ActiveCell) Then
ShouldPerformCleanupActions = True
Else
If ActiveCell <> "" Then Exit Function
If ActiveCell.Row <> 1 Then
Set cellAbove = ActiveCell.Offset(-1, 0)
If InStr(1, cellAbove, "date", vbTextCompare) > 0 Or VBA.IsDate(cellAbove) Then
ShouldPerformCleanupActions = True
End If
End If
End If
End If
End If
check_err:
End Function
Private Sub App_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
HidePickerAndCleanup
End Sub
Private Sub App_NewWorkbook(ByVal Wb As Workbook)
ShowPicker
End Sub
Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
ResetState
End Sub
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean)
ResetState
End Sub
Private Sub App_WindowResize(ByVal Wb As Workbook, ByVal Wn As Window)
PerformCleanupActions
End Sub
Private Sub App_SheetActivate(ByVal Sh As Object)
HidePickerAndCleanup
End Sub
Private Sub App_WorkbookActivate(ByVal Wb As Workbook)
ShowPicker
End Sub
|
|