下面程序只有一个工作表,若要动态产生多个工作表,并且可以在每个工作表中写入数据,怎么办?Private Sub Command1_Click()
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Name = "表1"
xlApp.ActiveWindow.Zoom = 100 xlSheet.Cells(1, 1).Value = "表1"
xlApp.Application.Visible = True
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = NothingEnd Sub
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Name = "表1"
xlApp.ActiveWindow.Zoom = 100 xlSheet.Cells(1, 1).Value = "表1"
xlApp.Application.Visible = True
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = NothingEnd Sub
Set xlSheet = xlBook.Worksheets(i) 'i是具体的数字,切换到哪个工作表