标题: [推荐]如何设置报表纸边距(ACCESS2000以下版本) [打印本页] 作者: zyz 时间: 2002-12-5 22:47 标题: [推荐]如何设置报表纸边距(ACCESS2000以下版本) How to Set Margins Via Code for a Report
You can set the margins for a report via code prior to previewing or printing a report. The code below should be placed in a general db module and be called first then call the DoCmd.OpenReport Method. Note that this code works in Access 95 and above. Even though in Access 2002 (Xp) you can access the margin properties directly in design mode rather than using the PrtMip property, this code will also work on that version of Access for compatibility.
'-------------------Module Declarations----------------
Type str_PRTMIP
RGB As String * 28
End Type
Type type_PRTMIP
'Typed as longs due to Ansi to Unicode conversion
xLeftMargin As Long
yTopMargin As Long
xRightMargin As Long
yBottomMargin As Long
fDataOnly As Long
xItemSizeWidth As Long
yItemSizeHeight As Long
fDefaultSize As Long
xItemsAcross As Long
yColumnSpacing As Long
xRowSpacing As Long
rItemLayout As Long
rFastPrinting As Long
rDataSheetHeadings As Long
End Type
'------------------------Function-----------------------------
Public Function SetReportMarginDefault(strReportName As String, left!, top!, right!, bottom!)
Dim PrtMipString As str_PRTMIP
Dim PM As type_PRTMIP
Dim objRpt As Report
Dim tempPrtMip As String
LSet PM = PrtMipString
'Use 1440 for US (inches), 567 (rest of the world) (centimeters)
PM.xLeftMargin = left * 1440
PM.yTopMargin = top * 1440
PM.xRightMargin = right * 1440
PM.yBottomMargin = bottom * 1440
LSet PrtMipString = PM
objRpt.prtmip = PrtMipString.RGB
'Make sure report has the focus
DoCmd.SelectObject acReport, strReportName
'Save the Report
DoCmd.DoMenuItem 7, acFile, 4, , acMenuVer70