vb.net で Excel 用のサンプル アドインを作成します。
Imports System.Runtime.InteropServices
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim excelApp As Excel.Application
excelApp = CType(Marshal.GetActiveObject("Excel.Application"), Excel.Application)
' Dim xlwb As Excel.Workbook = Globals.ThisAddIn.Application.Worksheets.Add()
' dim sheet As Excel.Worksheet = xlwb.ActiveSheet
Dim sheet As Excel.Worksheet
sheet = excelApp.ActiveSheet
sheet.Range("A1").Value = "OK"
Me.Close()
End Sub
End Class
Excel のセルに値を設定しました : sheet.Range("A1").Value = "OK"
が、設定されません。なんで?どのように修正しますか?