求大神帮忙,谢谢哈,程序报错,说类型不匹配。报错 说为定义 Set excelsheet = excelbook.Worksheets("shee
Option ExplicitDim excel As Application
Dim excelbook As Workbook
Dim excelsheet As Workbook
Dim x(1 To 4, 1 To 4) As Integer
Private Sub Command1_Click()
Randomize
Dim i, j As Integer
For i = 1 To 4
For j = 1 To 4
x(i, j) = 100 * Rnd()
Next j
Next i
excel1.Range("a1:d4").Value = x
excel1.Range("a1:d4").Select
Set excelchart = excel.Charts.Add
excelsheet.Application.Visible = True
excelsheet.SaveAs App.Path + "\test.xls"
End Sub
Private Sub Form_Load()
Set excel = CreateObject("Excel.application")
Set excelbook = excel.Workbooks().Add
Set excelsheet = excelbook.Worksheets("sheet1")
End Sub
Private Sub form_unload(cancel As Integer)
excelsheet.Application.Quit
Set excelsheet = Nothing
End Sub
End Sub