Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Excel = Microsoft.Office.Interop.Excel
- Imports Microsoft.Office
- Public Class Form7
- Dim appXL As Excel.Application = Nothing
- Dim wbXL As Excel.Workbook = Nothing
- Dim shXL As Excel.Worksheet = Nothing
- Dim raXL As Excel.Range = Nothing
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- 'Start Excel and get Application Object
- appXL = CreateObject("Excel.Application")
- appXL.Visible = True
- ' Add a new workbook
- wbXL = appXL.Workbooks.Add
- 'shXL = wbXL.Sheets("Sheet2")
- ' shXL.Activate()
- 'appXL.UserControl = True
- 'raXL = Nothing
- 'wbXL = Nothing
- 'shXL = Nothing
- 'appXL = Nothing
- Exit Sub
- Err_Handler:
- MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- raXL = Nothing
- shXL = Nothing
- wbXL = Nothing
- appXL.Quit()
- appXL = Nothing
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement