title: Referencing an excel sheet from a Windows Form in Document Level Customization
body: <p>I thought I'd try to learn VB.net and start with some VSTO (VS2012).   I'm trying to do an Excel Document Customization with a separate Windows Form in it (.show on load).  I can get the form to open on loading the doc.  I found lots of examples of how to put Windows Form Controls in the document on MSDN (and figured out how to do that), but I'm having trouble referencing parts of the Excel document from the Windows Form.</p>
  
  <p>So for example on the windows form called Main Control I tried to add this sub to a button:</p>
  
  <pre><code>Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  
      Try
          Dim baba As Sheet1
          baba.Cells(1, 2).Value = "Llaslmasd"
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
   End Sub
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>        Dim baba As New Sheet1
  </code></pre>
  
  <p>and</p>
  
  <pre><code>        Dim baba As WorkSheet
          baba = Sheet1
  </code></pre>
  
  <p>What is the correct way to reference the sheet if it is not a shared member, or if I should make it shared, how do I do that?</p>
  
  <p>Will things break if I programatically try to insert sheets from other (non-incorporated workbooks and therefore change sheet index?).</p>
  
  <p>Sorry if my English is wrong or my formatting of the question is bad, I'm still going over examples.</p>