Visual Basic Example #1

Here's an example which illustrates many of Milestones Professional's OLE Automation methods.  It builds a simple schedule, adds curtains, shades a task line and adds a duration SmartColumn. Try this example
    
The Code: 
     
Sub Main()
Dim objproject, objmilestones, tasks, T As Object

'Create the Milestones object
Set objmilestones = CreateObject("Milestones")

'Start Milestones
objmilestones.Activate

'set up a column, 2 inches wide
objmilestones.SetColumnWidth 1, 2

'Set up the toolbox to have a variety of symbols and colors
For ncounter = 0 To 11
    objmilestones.settoolboxsymbolproperty ncounter + 1, "Type", ncounter + 1
    objmilestones.settoolboxsymbolproperty ncounter + 1, "FillColor", ncounter + 1
    objmilestones.settoolboxsymbolproperty ncounter + 1, "DatePosition", ncounter + 2
    objmilestones.settoolboxsymbolproperty ncounter + 1, "ShowShadow", "on"
    objmilestones.settoolboxsymbolproperty ncounter + 1, "ShadowColor", 8
    objmilestones.settoolboxsymbolproperty ncounter + 1, "ShadowSize", 2
    objmilestones.settoolboxsymbolproperty ncounter + 1, "DateBack", "Transparent"
Next ncounter

'Add tasks and symbols to the schedule
For ncounter = 0 To 11
    Dim startsymboltype As Integer
    startsymboltype = ncounter * 2 + 1
    strTemp = "This is Task Row " + CStr(ncounter)

    objmilestones.PutCell ncounter + 1, 1, strTemp

    strTemp = CStr(ncounter + 1) + "/12/2000"

    objmilestones.AddTaskUsingDuration ncounter + 1, strTemp, startsymboltype, ncounter  + 1, 0, startsymboltype + 1, 55, "day"

    objmilestones.settasklinegrid ncounter + 1, 0, ncounter + 1, 0
    objmilestones.settasklinegrid ncounter + 1, 1, ncounter + 1, 0
    objmilestones.settasklinegrid ncounter + 1, 2, ncounter + 1, 0

Next ncounter

'shade the 5th task line
objmilestones.SetTaskLineShade 5, 0, 2
objmilestones.SetTaskLineShade 5, 1, 15
objmilestones.SetTaskLineShade 5, 2, 18

'Add a %duration column
objmilestones.SetColumnWidth 6, 1#
objmilestones.SetColumnProperty 6, "SmartColumn", "duration"
objmilestones.SetColumnProperty 6, "TextAlign", 2
objmilestones.SetColumnProperty 6, "ColumnHeadingLine1", "Days"

'set the start and end dates
objmilestones.SetStartDate "01/01/2000"
objmilestones.SetEndDate "06/30/2001"

'set up curtains
objmilestones.AddCurtain "1/1/2000", "1/15/2000"
objmilestones.AddCurtain "4/1/2000", "4/15/2000"
objmilestones.AddCurtain "7/1/2000", "7/15/2000"
objmilestones.AddCurtain "10/1/2000", "10/15/2000"
objmilestones.AddCurtain "1/1/2001", "1/15/2001"
objmilestones.AddCurtain "4/1/2001", "4/15/2001"
objmilestones.SetCurtainProperties 1, "1/1/2000", "1/31/2000", 1, 18, 1, 0
objmilestones.SetCurtainProperties 2, "4/1/2000", "4/30/2000", 4, 15, 1, 0
objmilestones.SetCurtainProperties 3, "7/1/2000", "7/31/2000", 7, 12, 1, 0
objmilestones.SetCurtainProperties 4, "10/1/2000", "10/15/2000", 10, 9, 1, 0
objmilestones.SetCurtainProperties 5, "1/1/2001", "2/15/2001", 13, 6, 1, 0
objmilestones.SetCurtainProperties 6, "4/1/2001", "4/30/2001", 16, 3, 1, 0

objmilestones.Refresh

'keep the schedule open
objmilestones.keepscheduleopen

'Maximize the Milestones window
objmilestones.MaximizeWindow

Exit Sub

End Sub

 
To try this example:
Click here to download a Zip file (MilestonesVBExample1.Zip) containing the above VB code.
Click here to visit our main programmer's page.