'Imports System.Runtime.InteropServices Dim xlApp = CreateObject("Excel.Application") 'xlApp.Visible = True Dim xlBooks = xlApp.Workbooks 'Cドライブのルートフォルダで読み書きするのは避けましょう 'Dim bookHoge = xlBooks.Open("C:\Users.xls") Dim bookHoge = xlBooks.Open("C:\SAMPLE\Users.xls") Dim xlSheets = bookHoge.Worksheets Dim shtHoge = xlSheets("Sheet1") Dim xlRange As Object xlRange = shtHoge.Range("T1") xlRange.Value = TextBox1.Text Marshal.ReleaseComObject(xlRange) '★ xlRange = shtHoge.Range("T2") xlRange.Value = TextBox2.Text Marshal.ReleaseComObject(xlRange) '★ Marshal.ReleaseComObject(shtHoge) '★ Marshal.ReleaseComObject(xlSheets) '★ bookHoge.Save() bookHoge.Close() Marshal.ReleaseComObject(bookHoge) '★ Marshal.ReleaseComObject(xlBooks) '★ xlApp.Quit() Marshal.ReleaseComObject(xlApp) '★