目标时:我想保存Change
事件发生时,所有任务的UniqueID
和Text5
值之前。运行时错误1100试图在ProjApp_ProjectBeforeTaskChange“全选”(类模块内)
因此,我有一个Class模块clsTskUpdate
,我尝试将所有这些值保存在Dictionary
的ProjApp_ProjectBeforeTaskChange
事件中。
然而,因为我有一个主项目和几个子项目,我需要SelectAll
任务,并通过ActiveSelection.Tasks
循环得到他们UniqueID
硕士项目内(感谢@Rachel的Hettinger的帮助)。
的问题开始,每当我从组合框修改ActualFinish
值(如图所示的屏幕截图如下图):
我得到一个运行时错误“1100 “:
的方法是不是在这种情况下
在下面的林可e(Sub ProjApp_ProjectBeforeTaskChange
)
SelectAll
有没有人在这里知道如何处理它?我如何在任务更新之前使用SelectAll
来保存我的Dictionary
中的所有当前值?
类clsTskUpdate代码
Option Explicit
Public WithEvents ProjApp As Application
Private Sub ProjApp_ProjectBeforeTaskChange(ByVal Tsk As Task, ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)
RowIDChanged = Tsk.UniqueID
MsgBox Application.StatusBar
SaveStatusforAllTasks ' call SaveStatusforAllTasks Sub, which saves current status of Text5 ("Status") of all tasks
End Sub
'===================================================================
Sub SaveStatusforAllTasks()
Dim AllTasks As Tasks
Dim Tsk As Task
' ****** Get Error 1100 at the line below *****
SelectAll
Set AllTasks = ActiveSelection.Tasks
' add existing values of UniqueID and Text5 to Dictionary object
Set Dict = CreateObject("Scripting.Dictionary")
For Each Tsk In AllTasks
If Not Tsk Is Nothing Then
If Not Dict.exists(Tsk.UniqueID) Then
Dict.Add Tsk.UniqueID, Tsk.Text5
End If
End If
Next Tsk
End Sub
该项目代码
Private Sub Project_Change(ByVal pj As Project)
StatusRYGFieldUpdate
End Sub
普通模块代码
Option Explicit
Public StatusRYGView As New clsTskUpdate
Public RowIDChanged As Long
Public Const myDateFormat As String = "dd/mm/yy"
Public Dict As Object ' use a Dictionary to save previous values of all UniqueID and Text5 values ("Status")
Sub StatusRYGFieldUpdate()
Set StatusRYGView.ProjApp = Application
PaneClose ' should close the Split window (to make sure run-time error 1100 won't happen
Application.Calculation = pjManual
Application.ScreenUpdating = False
If UpdateViewFlag Then
FormatModifiedTasks ' call FormatModifiedTasks Sub, which updates all tasks that Text5 ("Status") were modified
End If
Application.Calculation = pjAutomatic
Application.ScreenUpdating = True
End Sub
如何处理保存的Text5值? –