Results 1 to 15 of 15

Thread: VBA to use all projects in folder as subprojects

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    VBAX Regular
    Joined
    Dec 2015
    Posts
    11
    Location
    I spoke too soon. I tried recording the macro differently. The problem wasn't in the Consolidate code, it was because I was trying to import the subproject to the same row each time. I tried the following and although I need to tweak it because it leaves empty spaces between the subprojects, it still imports them all.

    Sub InsertSubProjects()
    
        'Declare the variables
        Dim projPath As String
        Dim projFile As String
        Dim r As Long
            
        'Specify the path to the folder
        projPath = "C:\Users\isaacc\Documents\Schedules\Open_Jobs\"
        
        'Get the first file from the folder
        projFile = Dir(projPath & "*.mpp", vbNormal)
        r = 1
        
        Do While Len(projFile) > 0
            'MsgBox projFile
            
            SelectTaskField Row:=r, Column:="Name"
            ConsolidateProjects Filenames:=projFile, NewWindow:=False, HideSubtasks:=True
            
            'Get the next file from the folder
            projFile = Dir
            r = r + 1
        
        Loop
    
    End Sub
    Last edited by SamT; 02-06-2016 at 05:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •