求教vb建excel表格
有一些数据想通过vb做成表格。能增加删除。
Option Explicit Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Dim pid As Long Private Sub Form_Load() Dim xlApp As Excel.Application, xlBook As Excel.Workbook, xlsheet As Excel.Worksheet Me.Height = 10245 Me.Width = 11745 Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set xlBook = xlApp.Workbooks.Add pid = FindWindow("XLMAIN", "Microsoft Excel - Book1") SetParent pid, Me.hwnd MoveWindow pid, 0, 0, 780, 650, True Set xlsheet = xlBook.Sheets(1) xlsheet.Activate End Sub Private Sub Form_Unload(Cancel As Integer) Call KillProcess("EXCEL.EXE") Unload Me End Sub