Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
My good buddy Bill (no, not G) ran into an oddity when trying to automate the timeline shape. After you drop a timeline master to the page and set the begin-and-end dates, the time scale markers do not get updated. The labels for the begin-and-end dates are updated correctly. When you drop a milestone marker and set its date, the timeline even positions it correctly. There just seems to be something different with the time scale markers. If you right-click on the timeline, click “Configure Timeline…”, and click OK, the time scale markers magically get refreshed.
So how do you do this in code? Never fear, it’s possible. I should have put this in the last entry, but it didn’t cross my mind. Thanks, Bill. All you have to do is call the Timeline solution’s add-on, ts.
If you inspect the Action row that corresponds with Timeline shape, you’ll notice the following formula in Action cell: RUNADDONWARGS(“ts”, “/cmd=3”). This is what brings up the Configure Timeline dialog. If you call this add-on in code while AlertResponse is turned on, the dialog won’t appear, but rather it will refresh the time scale markers. To call the add-on in code, use the Run method of the Addon object that corresponds with the “ts” add-on.
Here it is in VBA:
Public Sub TimelineTest()
Dim theTimeline As Shape
Dim theMilestone As Shape
Application.AlertResponse = 1
Set theTimeline = Application.ActiveWindow.Page.Drop( _
Application.Documents.Item("TIMELN_M.VSS").Masters.ItemU("Block timeline"), _
5.610236, 5.511811)
theTimeline.CellsU("User.visBeginDate").FormulaU = _
Application.ConvertResult("1/1/2004", VisUnitCodes.visDate, VisUnitCodes.visInches)
theTimeline.CellsU("User.visEndDate").FormulaU = _
Application.ConvertResult("12/31/2004", VisUnitCodes.visDate, VisUnitCodes.visInches)
' Refresh the timeline, here it is...
Application.Addons("ts").Run "/cmd=3"
Set theMilestone = Application.ActiveWindow.Page.Drop( _
Application.Documents.Item("TIMELN_M.VSS").Masters.ItemU("Line milestone"), _
5.610236, 5.511811)
theMilestone.CellsU("User.visMilestoneDate").FormulaU = _
Application.ConvertResult("7/1/2004", VisUnitCodes.visDate, VisUnitCodes.visInches)
Application.AlertResponse = 0
End Sub
-Chris
This posting is provide “AS IS” with no warranties, and confers no rights.