可为什么我一用.PrintPreview就死机?
用.PrintOut就可打印不死机?
请帮我看一下代码.
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
'Set xlApp = New Excel.Application
'激活EXCEL应用程序
'打开工作簿,strDestination为一个EXCEL报表文件
Dim strSource, strDestination As String
strSource = App.Path & "\RegFee.xls"
'RegFee.xls就是一个模版文件
strDestination = App.Path & "\Temp1.xls"
FileCopy strSource, strDestination
xlApp.Visible = False '隐藏EXCEL应用程序窗口
Dim xlbook As Excel.Workbook
Set xlbook = xlApp.Workbooks.Open(strDestination)
Dim xlsheet As Worksheet
Set xlsheet = xlbook.Worksheets(8)
xlsheet.Cells(1, 1) = "使用信息"
xlsheet.Cells(2, 1) = "日期范围:" & DTPStart(0).Value & " - " & DTPStart(1).Value
'xlsheet.Cells(3, 1) = "**"
'xlsheet.Cells(3, 2) = "**"
'xlsheet.Cells(3, 3) = "**"
'xlsheet.Cells(3, 4) = "**"
Dim i As Integer
For i = 0 To Me.MSHFlexGrid1.Rows - 1
xlsheet.Cells(3 + i, 1) = MSHFlexGrid1.TextMatrix(i, 1)
xlsheet.Cells(3 + i, 2) = MSHFlexGrid1.TextMatrix(i, 2)
xlsheet.Cells(3 + i, 3) = MSHFlexGrid1.TextMatrix(i, 3)
xlsheet.Cells(3 + i, 4) = MSHFlexGrid1.TextMatrix(i, 4)
xlsheet.Cells(3 + i, 5) = MSHFlexGrid1.TextMatrix(i, 5)
Next i
'xlsheet.Cells(2 + i, 1) = "总计:"
'xlsheet.Cells(2 + i, 3) = CStr(Sum) & "元"