|
中间代码修改如下:
Dim xlApp As Excel.Application '定义EXCEL类
Dim xlBook As Excel.Workbook '定义工件簿类
Dim xlSheet As Excel.Worksheet '定义工作表类
'For i = 1 To 15
' lblName = "Label" & Format(i, "00")
' If Me.Child0.Form(lblName).Visible = True Then
' TP(i) = Me.Child0.Form(lblName).Caption
' j = i
' Else
' Exit For
' End If
'Next i
Dim stDocName As String
stDocName = ChrW(23548) & ChrW(20986) & ChrW(69) & ChrW(120) & ChrW(99) & ChrW(101) & ChrW(108)
DoCmd.OutputTo acForm, "StarShow", "MicrosoftExcelBiff8(*.xls)", "", True, "", 0
'DoCmd.RunMacro stDocName
'DoCmd.OutputTo acOutputForm, stDocName, acFormatXLS, , True
'AppActivate "Microsoft Excel"
Set xlApp = GetObject(, "Excel.Application")
'Set xlBook = GetObject("StarShow.xls")
'Debug.Print ActiveWindow.Caption
Set xlBook = xlApp.ActiveWorkbook
Set xlSheet = xlApp.ActiveSheet
'xlSheet.Activate
'xlApp.Visible = True
xlSheet.Cells(1, 1) = "编 号"
xlSheet.Cells(1, 2) = "姓 名"
xlSheet.Cells(1, 3) = "手 机"
xlSheet.Cells(1, 4) = "电 话"
就可以了,因为你对未获得Excel对象,所以出错 |
|