title: Specifying the location of an inlineshape in MS Word (VBA)
body: <p>I've been trying to adapt the method shown here: <a href="http://support.microsoft.com/kb/246299" rel="nofollow">http://support.microsoft.com/kb/246299</a> so that I can create a command button in word which will save the document and remove itself when clicked. I've been unable to figure out how to change the position of the button from the default of the top left of the first page however. Ideally I'd like the button to be generated at the end of the document and be centre aligned, or otherwise placed at the cursor position.</p>
  
  <p>Any advice would be very much appreciated :)</p>
  
  <p>Thank You.</p>
  
  <p>My VB.NET project code so far:</p>
  
  <pre><code>Dim shp As Word.InlineShape
  
  shp = wrdDoc.Content.InlineShapes.AddOLEControl(ClassType:="Forms.CommandButton.1")
  
  shp.OLEFormat.Object.Caption = "Save To Disk"
  
  shp.Width = "100"
  
  'Add a procedure for the click event of the inlineshape
  
  Dim sCode As String
  
  sCode = "Private Sub " &amp; shp.OLEFormat.Object.Name &amp; "_Click()" &amp; vbCrLf &amp; _
  
  "ActiveDocument.SaveAs(""" &amp; sOutFile &amp; """)" &amp; vbCrLf &amp; _
  
  "On Error GoTo NoSave" &amp; vbCrLf &amp; _
  
  "MsgBox ""Document Saved Successfully""" &amp; vbCrLf &amp; _
  
  "Dim o As Object" &amp; vbCrLf &amp; _
  
  "For Each o In ActiveDocument.InlineShapes" &amp; vbCrLf &amp; _
  
  "If o.OLEFormat.Object.Name = ""CommandButton1"" Then" &amp; vbCrLf &amp; _
  
  "o.Delete" &amp; vbCrLf &amp; _
  
  "End If" &amp; vbCrLf &amp; _
  
  "Next" &amp; vbCrLf &amp; _
  
  "Exit Sub" &amp; vbCrLf &amp; _
  
  "NoSave:" &amp; vbCrLf &amp; _
  
  "MsgBox ""Document Failed To Save""" &amp; vbCrLf &amp; _
  
  "End Sub"
  
  wrdDoc.VBProject.VBComponents("ThisDocument").CodeModule.AddFromString(sCode)
  
  wrdApp.Visible = True
  </code></pre>