Created
December 13, 2012 22:59
-
-
Save ricdeez/4280889 to your computer and use it in GitHub Desktop.
MS Project: List of tasks matching a pattern, sorted by one parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
%w( win32ole pp date ).each { |dep| require dep } | |
doc = 'C:\Users\rdapaz\Dropbox\Karara\Schedule\K2 Master Schedule - Delayed FAT Scenario.mpp' | |
mpp = WIN32OLE.new('MSProject.Application') | |
mpp.Visible = true | |
mpp.FileOpen(doc) | |
tasks = [] | |
mpp.ActiveProject.Tasks.each do |tsk| | |
if tsk && /\(Switchroom Workshop\)/i.match(tsk.Name) | |
# The win32ole library already parses the datetime in the format "%F %X %z" | |
start = tsk.Start.strftime("%d/%m/%Y") | |
finish = tsk.Finish.strftime("%d/%m/%Y") | |
tasks << [tsk.Name, tsk.Start, tsk.Finish] | |
end | |
end | |
tasks.sort { |a,b| a[1] <=> b[1]}.each do |desc, start, finish| | |
start = start.strftime("%d/%m/%Y") | |
finish = finish.strftime("%d/%m/%Y") | |
puts [desc, start, finish].join("|") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment