PDA

View Full Version : Adding Module to Global.mpt



SherryO
06-01-2007, 10:53 AM
I'm trying to add a module to Global.mpt the same way I modified Personal.xls with the code below. Does anyone know how to do that? Since MSProject doesn't support application.startuppath I don't know how to set the variable to global.mpt.
Thank you!!!

Sub ModToPersonal()
Application.ScreenUpdating = False
Dim Filt As String, Title As String, FilterIndex As Integer, i As Integer, FileName
Dim blnPersonal As Boolean
Dim FSO As Object, Folder As Object, File As Object
Dim PersonalXLS As Workbook

'****Create an instance of the FileSystemObject and obtain the excel startup folder
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(Application.StartupPath)

'****See if Personal.xls already exists
For Each File In Folder.Files
If UCase(File.Name) = "PERSONAL.XLS" Then
If WorkbookIsOpen(File.Name) Then
Set PersonalXLS = Application.Workbooks(File.Name)
Else
Set PersonalXLS = Application.Workbooks.Open(File.Path)
End If

blnPersonal = True
Exit For
End If
Next

'****If Personal.xls was not found, create Personal.xls workbook and hide it
If blnPersonal = False Then
Set PersonalXLS = Application.Workbooks.Add
PersonalXLS.SaveAs (Application.StartupPath & "\PERSONAL.xls")
Windows("PERSONAL.xls").Visible = False
End If

PersonalXLS.VBProject.VBComponents.Import ("\\Code\test.bas (file://\\Code\test.bas)")
ExitHere:
'****Clean up
PersonalXLS.Save
Set PersonalXLS = Nothing
Set FSO = Nothing
Set Folder = Nothing
Set File = Nothing
Application.ScreenUpdating = True
End Sub