Project_Change VBA代码(Microsoft Project)未被解雇

时间:2017-12-21 14:24:33

标签: vba ms-project microsoft-project-vba

我是VBA的新手,我正在尝试创建一个生成userform的宏,以允许用户输入UID号并输出总松弛。我还希望在计划中手动进行更改时更新总松弛输出。我的userform当前工作,但我似乎无法激活Project_Change方法。换句话说,我可以键入任何UID并获得所需的输出。但是,如果我更改计划中的松弛值,则松弛值将不会显示userform(或应打印“hi”的消息框)中的任何更改。提前谢谢!

项目模块代码:

Sub ShowSlack()
    UserForm10.Show False
End Sub

Private Sub Project_Change(ByVal pj As Project)
    MsgBox "hi"
    UserForm10.UpdateTotalSlack
End Sub

Userform模块代码:

Dim User_UID As Variant
Dim TSlack As Variant

Private Sub TextBox3_Change()
    User_UID = UserForm10.TextBox3.Value
    UpdateTotalSlack
End Sub

Sub UpdateTotalSlack()
    On Error Resume Next
    If Not User_UID = "" Then
        TSlack = ActiveProject.Tasks.UniqueID(User_UID).TotalSlack / 480
    Else
        TSlack = ""
    End If
    UserForm10.Label1.Caption = TSlack
End Sub

0 个答案:

没有答案