Page 事件發生於 Microsoft Access 設定列印報表的頁面格式之後,但是在列印該頁之前。 使用此事件可在頁面周圍繪製框線,或將其他圖形元素新增至頁面。
語法
表達。頁
詞 代表 Report 物件的變數。
傳回值
無
註解
若要在此事件發生時執行巨集或事件程序,請將 OnPage 屬性設定為巨集的名稱或 [事件程序]。
此事件發生在報表的所有 Format 事件之後,以及頁面的所有 Print 事件之後,但在實際列印頁面之前。
您通常會在「頁面」事件程序中使用「線條」、「圓形」或「PSet」方法,為頁面建立所需的圖形。
NoData 事件發生在報表的第一個 Page 事件之前。
範例
下列範例顯示如何使用 Line 方法在報表頁面周圍上畫出一個矩形。 根據預設,ScaleWidth 和 ScaleHeight 屬性會傳回報表的內部寬度和高度。
Private Sub Report_Page()
Me.Line(0, 0)-(Me.ScaleWidth, Me.ScaleHeight), , B
End Sub
下列範例會示範如何將浮水印新增至報表會在列印之前使用 Page事件。
Private Sub Report_Page()
Dim strWatermarkText As String
Dim sizeHor As Single
Dim sizeVer As Single
#If RUN_PAGE_EVENT = True Then
With Me
'// Print page border
Me.Line (0, 0)-(.ScaleWidth - 1, .ScaleHeight - 1), vbBlack, B
'// Print watermark
strWatermarkText = "Confidential"
.ScaleMode = 3
.FontName = "Segoe UI"
.FontSize = 48
.ForeColor = RGB(255, 0, 0)
'// Calculate text metrics
sizeHor = .TextWidth(strWatermarkText)
sizeVer = .TextHeight(strWatermarkText)
'// Set the print location
.CurrentX = (.ScaleWidth / 2) - (sizeHor / 2)
.CurrentY = (.ScaleHeight / 2) - (sizeVer / 2)
'// Print the watermark
.Print strWatermarkText
End With
#End If
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。