I'm aiming to create a simple ribbon with a button that set cell (A1) value to "Hello World!" in the active work sheet.
I have this code but it returns an error and I have no idea what I'm doing wrong.
Screenshot of error:
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