I'm trying to add a ribbon toolbar into Excel by creating a Add-in in Visual Studio. That ribbon will have butons that, when clicked, will insert some names into the active cell of the active sheet where the button was pressed. For instance, I have a button btnInserirLinha that when I click I want to write "Test" to the cell where the cursor is on the sheet.
I've the following code but this is for reference a closed workbook. I need to reference the actual workbook.
How can I do this?
Thanks for your help.
Public Class Ribbon1
Private Sub btnInserirLinha_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles btnInserirLinha.Click
Dim objExcelApp As New Excel.Application
Dim objExcelBook As Excel.Workbook
Dim objExcelSheet As Excel.Worksheet
objExcelBook = objExcelApp.Workbooks.Open("c:\STDJUNE.xls")
objExcelSheet = objExcelBook.ActiveSheet