Update VBA code module in distributed MS Project g

2020-05-08 08:09发布

I am responsible to modify the Global file of MS Project. It contains a custom made module which is constantly updated. I am distributing it to other users which do not have the computer skills to update their own file (I know it's just copy paste). I would like to know if there is a way I can code something in the Global file which checks for the latest version that is stored on a shared drive and copies and pastes in the other users computers?

1条回答
再贱就再见
2楼-- · 2020-05-08 08:32

Use the Project_Open event in the ThisProject module of your global.mpt file to periodically update the code in a different module in the same file (e.g. the "Main" module):

Dim LastUpdated As Date

Private Sub Project_Open(ByVal pj As Project)

    ' run update if more than 1 hour since last update
    If Now - LastUpdated > (1 / 24) Then
        With ThisProject.VBProject
            .VBComponents.Remove .VBComponents("Main")
            .VBComponents.Import "c:\temp\main.bas"
        End With
        LastUpdated = Now
    End If

End Sub
查看更多
登录 后发表回答