Update VBA code module in distributed MS Project global.mpt files

让人想犯罪 __ 提交于 2019-12-02 17:23:27

问题


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:


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


来源:https://stackoverflow.com/questions/46671137/update-vba-code-module-in-distributed-ms-project-global-mpt-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!