title: Writing a value to an Excel cell
body: <p>I'm aiming to create a simple ribbon with a button that set cell (A1) value to "Hello World!" in the active work sheet.</p>
  
  <p>I have this code but it returns an error and I have no idea what I'm doing wrong.</p>
  
  <p>Screenshot of error:</p>
  
  <p><a href="https://i.stack.imgur.com/BRgvH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BRgvH.jpg" alt="enter image description here"></a></p>
  
  <p>Code:</p>
  
  <pre><code>Imports Microsoft.Office.Tools.Ribbon
  Imports Microsoft.Office.Interop.Excel
  
  Public Class Ribbon1
  
      Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
  
      End Sub
  
      Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
          Dim xlApp As New Excel.Application
          Dim xlBook As Excel.Workbook
          Dim xlSheet As Excel.Worksheet
  
          xlBook = xlApp.ActiveWorkbook
          xlSheet = xlBook.ActiveSheet
  
          With xlSheet
              .Range("A1").Value = "Hello World!"
          End With
      End Sub
  
  End Class
  </code></pre>