Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Project 2010 Standard - VBA export to Excel; Latest Baseline

$
0
0

I am using Project 2010 Standard.  I have written a VBA module to export certain fields of my Projects to Excel.  I use the same Module for multiple project files.  Two of the fields I export are baseline starts and baseline finishes for each task in a Project file.  The problem I have is that each of my projects are at different baselines, so I need to go into my VBA code and change which baseline start and finish I want to export.  Is there a way to write the code to look for the latest baseline set for each project file, and export the start and finishes stored with the latest baseline?  My first approach was to write the code so an input box opens asking the user to input the correct baseline number, but I don't know how to substitute the Task.BaselineStart field with the user specified baseline number (i.e. Baseline2Start).

Below is my Module:

Sub InchstoneExport()

    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    Set xlApp = New Excel.Application
    xlApp.Visible = True
    AppActivate "Microsoft Excel"
    Set xlBook = xlApp.Workbooks.Open("G:\Users\Gilbert_Shawn\MS_Project\InchstoneCount_working.xlsm")
    Set xlSheet = xlBook.Worksheets("RawData")
       
    For Each Task In ActiveProject.Tasks
        xlSheet.cells(Task.ID + 2, 1).Value = Task.ID
        xlSheet.cells(Task.ID + 2, 2).Value = Task.Name
        xlSheet.cells(Task.ID + 2, 3).Value = Task.BaselineStart
        xlSheet.cells(Task.ID + 2, 4).Value = Task.BaselineFinish
        xlSheet.cells(Task.ID + 2, 5).Value = Task.Start
        xlSheet.cells(Task.ID + 2, 6).Value = Task.Finish
        xlSheet.cells(Task.ID + 2, 7).Value = Task.ActualStart
        xlSheet.cells(Task.ID + 2, 8).Value = Task.ActualFinish
        xlSheet.cells(Task.ID + 2, 9).Value = Task.Summary
        xlSheet.cells(Task.ID + 2, 10).Value = Task.Recurring
        xlSheet.cells(Task.ID + 2, 11).Value = Task.Flag1
    Next Task

End Sub


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>