locked
Opening MS Project files in a directory RRS feed

  • Question

  • I want to write in a folder location into this vba code then open all the project files, then close them.
    Later on I will put some simple instructions inside the loop, like change the status date. 
    So far I have the code below,
    Not entirely sure what I am doing.
    Any help would be greatly appreciated.

    Sub OpenFile1()

    Dim appProj As MSProject.Application
    Dim aProg As MSProject.Project

    Set FileSystemOBJ = CreateObject("MSProject.Application")
    Set FolderOBJ = FileSystemOBJ.GetFOlder("C:\Users\mark\Desktop")

    For Each fileobj In FolderOBJ.Files


    Next fileobj

    End Sub

    Wednesday, July 3, 2013 5:16 AM

Answers

  • If your code is from withing Project, then something like this should work. Set a reference to MS Scripting Runtime: I'm not sure of the specific object types in MS Project - I'm just projecting based on Excel....

    Sub OpenFile1()

        Dim aProj As Project 'whatever the file object type is....
        Dim FolderObj As Scripting.Folder
        Dim FileSystemOBJ As Scripting.FileSystemObject
        Dim FileObj As Scripting.File

        Set FileSystemOBJ = New Scripting.FileSystemObject
        
        Set FolderObj = FileSystemOBJ.GetFolder("C:\Users\mark\Desktop")

        For Each FileObj In FolderObj.Files
            If FileObj.Name Like "*.mpp" Then
                Set aProj = Projects.Open(FolderObj.Path & "\" & FileObj.Name)
                'Other code
                aProj.Close True
            End If
        Next FileObj

    End Sub

    • Marked as answer by Dummy yoyo Tuesday, July 9, 2013 9:21 AM
    Wednesday, July 3, 2013 4:13 PM