Jan 08
One project that I’m currently working on calls for taking tasks out of a MS Project document and moving them to a Powerpoint presentation with pretty formatting. Maybe I’ll blog about the whole thing later. Here’s a quick program I wrote to dump out all the tasks from a test project in a somewhat formatted output to verify I could actually get the tasks:
#!C:\ruby\bin\ruby.exe
require 'exo/iswindows'
if !RUBY_PLATFORM.isWindows?
puts "This program only runs under Windows!"
exit
end
require 'win32ole'
def fmtMSProjDate(msdate)
yr = msdate[/^(\d\d\d\d)\/\d\d/, 1]
mth = msdate[/^\d\d\d\d\/(\d\d)\/\d\d/, 1]
day = msdate[/^\d\d\d\d\/\d\d\/(\d\d) /, 1]
return "#{mth}/#{day}/#{yr}"
end
def getAbsolutePathName(file)
fso = WIN32OLE.new('Scripting.FileSystemObject') ## VBA File System commands
return fso.GetAbsolutePathName(file)
end
if !ARGV[0][/\:/]
file = "#{Dir.pwd}/#{ARGV[0]}"
else
file = ARGV[0]
end
app = WIN32OLE.new('MSProject.Application')
app.FileOpen(getAbsolutePathName(file))
pj = app.ActiveProject
#app.Visible = true
puts "\nProject: #{pj.Title.ljust(60)}" + fmtMSProjDate(pj.Start.to_s) + " " + fmtMSProjDate(pj.Finish.to_s) + "\n\n"
pj.Tasks.each do |t|
puts t.ID.to_s.rjust(5) + " " + "| "*t.OutlineLevel + t.Name.ljust(63-(t.OutlineLevel*2)) + fmtMSProjDate(t.Start.to_s) + " " + fmtMSProjDate(t.Finish.to_s)
end
app.Quit
Here’s my test run:
C:\Server17\Dev\Ruby>ruby listmsproject.rb invasionofpluto.mpp
Project: invasionofpluto.mpp 01/08/2010 10/16/2026
1 | Invasion of Pluto 01/08/2010 10/16/2026
2 | | Get Ready 01/08/2010 09/25/2023
3 | | | Design Invasion ships 01/08/2010 03/08/2012
4 | | | Build Invasion Ships 03/09/2012 09/25/2023
5 | | | Train the Troops 08/01/2011 12/01/2022
6 | | Travel to Pluto 09/26/2023 08/26/2026
7 | | Attack! 08/27/2026 10/15/2026
8 | | | Look things over 08/27/2026 09/03/2026
9 | | | Plan the invasion 09/11/2026 09/11/2026
10 | | | Invade 10/15/2026 10/15/2026
11 | | Stand around and admire our new conquest 10/16/2026 10/16/2026
Yeah, its a silly example, but I really can’t use any of my customer’s plans on here






