页面总数和打印方向什么的都是参考的SPREAD的例程
页面总数设置:在frmPrint窗体里
Private Sub Form_Activate()
fpSpreadPreview1.hWndSpread = fps.hWnd
txtPage.Text = fpSpreadPreview1.PageCurrent & "/" & fps.PrintPageCount
End Sub
这个是保存以后的设置,包括打印方向和其他设置
With frmPrint.fps
For i = 0 To 3
If optPrintType(i).Value = True Then
.PrintType = i
Exit For
End If
Next
If .PrintType = 3 Then '页码范围
.PrintPageStart = Val(txtStart.Text)
.PrintPageEnd = Val(txtEnd.Text)
End If
If optLandscape.Value = True Then
.PrintOrientation = PrintOrientationLandscape
' Printer.Orientation = vbPRORLandscape
Else
.PrintOrientation = PrintOrientationPortrait
' Printer.Orientation = vbPRORPortrait
End If
.PrintMarginTop = Val(txtTop.Text) * 567
.PrintMarginBottom = Val(txtBottom.Text) * 567
.PrintMarginLeft = Val(txtLeft.Text) * 567
.PrintMarginRight = Val(txtRight.Text) * 567
tmp = ""
If InStr(txtHeader.Text, vbCrLf) > 0 Then '有换行
pl = Split(txtHeader.Text, vbCrLf)
For i = LBound(pl) To UBound(pl)
txtHeader.Text = CStr(pl(i))
tmp = tmp & GetData(txtHeader, Combo1.Text)
If i < UBound(pl) Then tmp = tmp & "/n"
Next
Else
tmp = GetData(txtHeader, Combo1.Text)
End If
.PrintHeader = tmp
tmp = ""
If InStr(txtFooter.Text, vbCrLf) > 0 Then '有换行
pl = Split(txtFooter.Text, vbCrLf)
For i = LBound(pl) To UBound(pl)
txtFooter.Text = CStr(pl(i))
tmp = tmp & GetData(txtFooter, Combo2.Text)
If i < UBound(pl) Then tmp = tmp & "/n"
Next
Else
tmp = GetData(txtFooter, Combo2.Text)
End If
.PrintFooter = tmp
.PrintColHeaders = chkColHeader.Value
.PrintRowHeaders = chkRowHeader.Value
.PrintGrid = chkGridLine.Value
.PrintBorder = chkBorder.Value
.PrintCenterOnPageH = chkHCenter.Value
.PrintCenterOnPageV = chkVCenter.Value
If Len(txtTitle.Text) > 0 Then
myTitle.Title = txtTitle.Text
myTitle.Name = txtTitle.Font.Name
myTitle.Size = txtTitle.Font.Size
myTitle.Bold = txtTitle.Font.Bold
myTitle.Italic = txtTitle.Font.Italic
myTitle.Underline = txtTitle.Font.Underline
myTitle.Strikethrough = txtTitle.Font.Strikethrough
If .ColHeaderRows = 1 Then
.ColHeaderRows = .ColHeaderRows + 1
For i = 1 To .MaxCols
.Col = i
.Row = SpreadHeader
tmp = .Text
.Row = SpreadHeader + 1
.Text = tmp
Next
End If
.Col = 1
.Row = SpreadHeader
.Text = myTitle.Title
.Font.Name = myTitle.Name
.Font.Size = myTitle.Size
.FontBold = myTitle.Bold
.FontItalic = myTitle.Italic
.FontUnderline = myTitle.Underline
.FontStrikethru = myTitle.Strikethrough
.AddCellSpan 1, SpreadHeader, .MaxCols, 1
' .TypeHAlign = TypeHAlignCenter
End If
End With
For Each X In Printers
If X.DeviceName = cmbPrinter.Text Then
Set Printer = X
frmPrint.fps.hDCPrinter = X.hDC
Debug.Print frmPrint.fps.hDCPrinter
Printer.PaperSize = Val(cmbPaperSize.Tag)
If Printer.PaperSize = 256 Then '自定义
Printer.Width = Val(txtWidth.Text) * 567
Printer.Height = Val(txtHeight.Text) * 567
End If
Printer.PaperBin = Val(cmbPaperbin.Tag)
Exit For
End If
Next
Printer.Copies = Val(txtCopies.Text) |