VB调用Excel软件实现打印预览功能
VB调用Excel软件实现打印预览功能 C:\打印.xls VB怎么实现预览C:\打印.xls中Sheet1表中内容
程序代码:
Option Explicit Dim EelApp As Excel.Application Dim EelWork As Excel.Workbook Dim EelSheel As Excel.Worksheet Private Sub Command1_Click() Set EelApp = New Excel.Application EelApp.Visible = True Set EelWork = EelApp.Workbooks.Open("C:\打印.xls") Set EelSheel = EelWork.Worksheets(1) EelSheel.PrintPreview '打印预览 End Sub Private Sub Form_Unload(Cancel As Integer) EelApp.Workbooks.Close EelApp.Quit Set EelSheel = Nothing Set EelWork = Nothing Set EelApp = Nothing End Sub注意,必须事先在VB6中引用Excel库。