jump to navigation

VB : data report 橫印問題… 13 七月, 2007

Posted by leterboy in Tech Learning.
10 comments

當您在使用 VB6 中的 DataReport
時,有沒有遇到過一種情形:系統設定的印表機列印方向預設是直印,而您的報表卻是橫式的,但是您卻無法更改印表機的列印方向,除非您到控制台的印表機中去更改預設為橫印!

如果您不希望使用者自行去更改印表機的設定,您就必須在程式中幫他設定好,以下的模組檔案
Orient.bas 就是用來設定印表機的直印或橫印的,說明如下:


Sub ChngPrinterOrientationLandscape(ByVal frm As
For
m):設定為直印

Sub ChngPrinterOrientationPortrait(ByVal frm As Form):設定為橫印

在程式中使用方式如下:

1、設定為直印:ChngPrinterOrientationPortrait
Me

2、設定為橫印:ChngPrinterOrientationLandscape Me

註1:此方法也可適用於 Crystal
Report。

註2:VB6 sp5 之後可直接使用 DataReport1.Orientation 來設定直橫印。

  • 底下內容摘自http://www.blueshop.com.tw/board/show.asp?subcde=BRD20030609120244K8T&fumcde=FUM20050124191756KKC&rplcnt=1

不可以指定紙張大小..我已經找遍了..

但可以用excel列印..以下是我以前所寫的.供您參考…..

Dim excelapp As Object

Dim excelwkb As Object

Dim excelsht As Object

Dim limitpp1 As Integer

   

Set excelapp = GetObject(App.Path & “\book1.xls")

Set excelsht = excelapp.Worksheets(1)

If smoke1 > 0 Then

   excelsht.Cells(3, 2) = smoke1

   excelsht.Cells(3, 3) = smoke1 * 49

   excelsht.Cells(15, 2) = smoke1

   excelsht.Cells(15, 3) = smoke1 * 49

   excelsht.Cells(46, 1) = “合計 " & smoke1 & “人"

end if

excelsht.PrintOut