Check if a code module exists in the Global.MPT instead of the ActiveProject does not work

BVOPP

Board Regular
Joined
Feb 9, 2015
Messages
57
In the internet I found an excel version and changed it for MS Project. The Set Module = ActiveProject.VBProject.VBComponents(name).CodeModule does work but the Set Module = GlobalMPT.VBProject.VBComponents(name).CodeModule does not give an error but it does not work either....
Any idea??

VBA Code:
Sub tester()

    Debug.Print Is_Module_Loaded("Module1")

End Sub


Public Function Is_Module_Loaded(name As String) As Boolean

    Dim Module As Object

    On Error Resume Next
    'Set Module = ActiveProject.VBProject.VBComponents(name).CodeModule
    Set Module = GlobalMPT.VBProject.VBComponents(name).CodeModule
    On Error GoTo 0

    Is_Module_Loaded = Not Module Is Nothing

    If Not Is_Module_Loaded Then
        MsgBox ("MODULE: " & name & " is not installed please add")
    Else
        MsgBox ("MODULE: " & name & " is already installed")
    End If

End Function
 
and yes it is a company laptop and MS Project license as well.
Then Trust access to the VBA project object model has probably been disabled in the registry by the company as it is a higher security risk.
 
Upvote 0
Solution

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Then try this still:
VBA Code:
    Set GlobalMPT = Application.VBE.VBProjects("Global.mpt")
Of course, “Trust access to the VBA project” is required

If it works, pay tribute of thanks to ChatGPT.

Artik
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top