把前几天的学习结果向老师汇报如下:
原程序:
Private Sub Com1_Click()
Dim EXAPP As Excel.Application
Dim WB As Excel.Workbook
Dim sht As Excel.Worksheet
Set EXAPP = CreateObject("excel.application")
Set WB = EXAPP.Workbooks.Open(App.Path & "\lian01.xls")
Set sht = WB.Application.Worksheets("sheet1")
sht.Range("A2") = Text1.Text
sht.Range("C2") = CStr(Date)
sht.Range("B3") = Text2.Text
sht.Range("B4") = Text3.Text '写入方式
sht.Range("B5") = Text4.Text
sht.Range("C" & 6) = "姜
欢" '写入方式二
EXAPP.Visible = False
sht.PrintPreview
'打印预览
EXAPP.Worksheets("sheet1").PrintOut
WB.Close
Set sht = Nothing
Set WB = Nothing
Set EXAPP = Nothing
End Sub
语句Worksheets("sheet1")中sheet1试着用我的文件名代替为什么不行呢?