1、 这里有一个快速打印MSFlexGrid控件内容的方法: Printer.PaintPicture MSFlexGrid_Name.Picture, 0, 0 Printer.EndDoc 如果想打印满页面的整个长度,请在前面添加下面2个语句: Dim old_width as Integer MSFlexGrid_Name.width=printer.width 然后,再在尾部添加: MSFlexGrid_Name.width=old_width ------------------------------ 2、引用Excel Dim xlsApp As Excel.Application Dim xlsBook As Excel.Workbook Dim xlssheet As Excel.Worksheet Set xlsApp = New Excel.Application Set xlsApp = CreateObject("Excel.Application") xlsApp.Visible = False Set xlsBook = xlsApp.Workbooks.Open(app.path & "\filename.xls") Set xlssheet = xlsBook.Worksheets(1) for i=1 to mshflexgrid.rows for j=1 to mshflexgrid.cols With xlssheet mshflexgrid.row=i mshflexgrid.col=j .Cells(i, j) = mshflexgrid.text End With next j next i xlsBook.Save xlssheet.PrintPreview xlsApp.Quit Set rsExesList = Nothing Set cnExesList = Nothing Set xlsApp = Nothing Set xlsBook = Nothing Set xlssheet = Nothing
这里有一个快速打印MSFlexGrid控件内容的方法: Printer.PaintPicture MSFlexGrid_Name.Picture, 0, 0
Printer.EndDoc 如果想打印满页面的整个长度,请在前面添加下面2个语句: Dim old_width as Integer
MSFlexGrid_Name.width=printer.width 然后,再在尾部添加: MSFlexGrid_Name.width=old_width
------------------------------
2、引用Excel
Dim xlsApp As Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlssheet As Excel.Worksheet
Set xlsApp = New Excel.Application
Set xlsApp = CreateObject("Excel.Application")
xlsApp.Visible = False
Set xlsBook = xlsApp.Workbooks.Open(app.path & "\filename.xls")
Set xlssheet = xlsBook.Worksheets(1)
for i=1 to mshflexgrid.rows
for j=1 to mshflexgrid.cols
With xlssheet
mshflexgrid.row=i
mshflexgrid.col=j
.Cells(i, j) = mshflexgrid.text
End With
next j
next i
xlsBook.Save
xlssheet.PrintPreview
xlsApp.Quit
Set rsExesList = Nothing
Set cnExesList = Nothing
Set xlsApp = Nothing
Set xlsBook = Nothing
Set xlssheet = Nothing