---------------------------------------
Option Explicit
Dim ExcelApp As Excel.Application
Dim ExcelCht As Excel.Chart
Dim ExcelSht As Excel.Worksheet
Dim ExcelWkb As Excel.Workbook
Dim MyExcel As Boolean
Private Sub Command1_Click()
On Error Resume Next
Err.Clear
Set ExcelApp = GetObject(, "Excel.Application"

If Err.Number <> 0 Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application"

If Err.Number <> 0 Then
MsgBox "Error: " & Err.Description
Else
MyExcel = True
End If
Else
MyExcel = False
End If
ExcelApp.Visible = True
Check1.Value = vbChecked
Command2.SetFocus
End Sub
Private Sub Command10_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Set ExcelWkb = ExcelApp.Workbooks.Add
Set ExcelSht = ExcelWkb.Worksheets(1)
Check2.Value = vbChecked
Command3.SetFocus
End Sub
Private Sub Command3_Click()
Dim i As Integer
Dim j As Integer
For i = 1 To 4
For j = 1 To 10
ExcelSht.Cells(j, i) = Rnd() * 100
Next j
Next i
Check3.Value = vbChecked
Command4.SetFocus
End Sub
Private Sub Command4_Click()
ExcelSht.Range("A1

10"

.NumberFormat = "0.00"
Check4.Value = vbChecked
Command5.SetFocus
End Sub
Private Sub Command5_Click()
Set ExcelCht = ExcelWkb.Charts.Add
ExcelCht.ChartType = xlLineMarkers
ExcelCht.SetSourceData ExcelSht.Range("A1

10"

, xlColumns
ExcelCht.HasTitle = True
ExcelCht.ChartTitle.Characters.Text = "My Data"
ExcelCht.Axes(xlCategory, xlPrimary).HasTitle = True
ExcelCht.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "X-Axis"
ExcelCht.Axes(xlValue, xlPrimary).HasTitle = True
ExcelCht.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Data Series"
Check5.Value = vbChecked
Command6.SetFocus
End Sub
Private Sub Command6_Click()
ExcelCht.ChartArea.Select
ExcelCht.ChartArea.Copy
Image1.Picture = Clipboard.GetData(vbCFBitmap)
Check6.Value = vbChecked
Command7.SetFocus
End Sub
Private Sub Command7_Click()
If Len(Dir(App.Path & "\test.xls"

) <> 0 Then
Kill App.Path & "\test.xls"
End If
ExcelWkb.SaveAs App.Path & "\test.xls"
Check7.Value = vbChecked
Command8.SetFocus
End Sub
Private Sub Command8_Click()
ExcelWkb.Close False
Check8.Value = vbChecked
Command9.SetFocus
End Sub
Private Sub Command9_Click()
If MyExcel Then
ExcelApp.Quit
End If
Check9.Value = vbChecked
Command10.SetFocus
End Sub
Private Sub Form_Load()
Randomize
End Sub
---------------------------------------------------