title: How do I programmatically drop a Milestone onto a Block Timeline in Visio
body: <p>I'm trying to programmatically create a timeline and markers using the Visio 2010 COM Interops.  My code is based off of Chris Castillo's 2 part blog posting (<a href="http://blogs.msdn.com/b/chcast/archive/2004/11/12/256599.aspx" rel="nofollow noreferrer">Part 1</a>, <a href="http://blogs.msdn.com/b/chcast/archive/2004/11/17/259191.aspx" rel="nofollow noreferrer">Part 2</a>), which is the only semi-complete example I've been able to find on how to do this.  However his blog (from 2004) doesn't seem to work right.  The milestones are not really connected to the timeline, and updating their date does not get them to move to the right place.</p>
  
  <p>Any suggestions or fixes?</p>
  
  <p><img src="https://i.stack.imgur.com/F4S5e.png" alt="enter image description here"></p>
  
  <pre><code>Imports Microsoft.Office.Interop.Visio
  Imports System.Diagnostics.CodeAnalysis
  Imports System.Runtime.InteropServices
  </code></pre>
  
  <p>...</p>
  
  <pre><code>Dim VisioApp As New Application
  
  Dim myDoc As Document = VisioApp.Documents.Add("")
  Dim myPage As Page = myDoc.Pages.Item(1)
  
  Dim TimelineStencils As Document =
      VisioApp.Documents.Add("Timeline Shapes.vss")
  
  Dim theTimeline As Shape
  Dim theMilestone As Shape
  
  VisioApp.AlertResponse = 1
  
  theTimeline = myPage.Drop(
      TimelineStencils.Masters.ItemU("Block timeline"), 5.610236, 5.511811)
  
  theTimeline.CellsU("User.visBeginDate").FormulaU = _
          VisioApp.ConvertResult(
              "1/1/2004", VisUnitCodes.visDate, VisUnitCodes.visInches)
  
  theTimeline.CellsU("User.visEndDate").FormulaU = _
      VisioApp.ConvertResult(
          "12/31/2004", VisUnitCodes.visDate, VisUnitCodes.visInches)
  
  VisioApp.Addons("ts").Run("/cmd=3")
  
  theMilestone = myPage.Drop( _
      TimelineStencils.Masters.ItemU("Line milestone"), _
      5.610236, 5.511811)
  
  theMilestone.CellsU("User.visMilestoneDate").FormulaU = _
      VisioApp.ConvertResult(
          "7/1/2004", VisUnitCodes.visDate, VisUnitCodes.visInches)
  
  VisioApp.AlertResponse = 0
  </code></pre>