Dim p = Process.GetProcessesByName("Excel")
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim xls As Object = Nothing Try xls = GetObject(, "Excel.Application") Catch 'ex As Exception '起動済みでない場合、例外となる End Try If xls Is Nothing Then MessageBox.Show(Me, "Excel は起動されていません。", "起動判定", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If Dim xlApp = DirectCast(xls, Excel.Application) xlApp.Visible = True ' '中略 ' If Marshal.IsComObject(xlApp) Then Marshal.ReleaseComObject(xlApp) xlApp = Nothing End If End Sub