Tor zum „SelectAll“ versucht: Ich versuche, alle die Aufgabe des UniqueID
und Text5
Werte zu speichern, bevor ein Change
Ereignis eintritt.Laufzeitfehler 1100, wenn in ProjApp_ProjectBeforeTaskChange (innerhalb der Klasse Module)
Daher habe ich ein Klassenmodul clsTskUpdate
, wo ich versuche, alle diese Werte in einem Dictionary
in ProjApp_ProjectBeforeTaskChange
Ereignis zu speichern.
jedoch, da ich einen Master-Projekt haben, und mehrere Teilprojekte, muss ich SelectAll
Aufgaben und Schleife durch ActiveSelection.Tasks
ihre UniqueID
innerhalb des Master Projekt zu erhalten (dank der Hilfe von @Rachel Hettinger).
Das Problem beginnt, dass, wenn ich den Wert von ActualFinish
aus der Combo-Box ändern (wie im Screenshot unten dargestellt):
Ich erhalte einen Laufzeitfehler ‚1100 ‚:
Verfahren nicht in dieser Situation ist
Am folgenden lin e (innen Sub ProjApp_ProjectBeforeTaskChange
)
SelectAll
hier jemand Kennt wie man damit umgehen? Wie kann ich die SelectAll
verwenden, bevor die Aufgabe ihre Werte aktualisiert, um alle aktuellen Werte in meinem Dictionary
zu speichern?
Klasse clsTskUpdate-Code
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
Dieses Projekt-Code
Private Sub Project_Change(ByVal pj As Project)
StatusRYGFieldUpdate
End Sub
Regular Modulcode
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
Was machen Sie mit gespeicherten Text5-Werten? –