共用方式為


(Access) 的 Report.FontName 屬性

在下列情況下,使用 FontName 屬性來指定文字的字型:

  • 在表單及報表上顯示或列印控制項時。
  • 當在報表上使用 Print 方法。

讀取/寫入的 String

語法

運算式FontName

表達 代表 Report 物件的變數。

註解

FontName 屬性設定為顯示文字的字型名稱。

您可以使用控制項的預設控制項樣式或 Visual Basic 中的 DefaultControl 屬性來設定這個屬性的預設值。

對於報表,您可以設定這個屬性只能在一個事件程序或在 OnPrint 事件屬性設定值所指定的巨集。

字型可用與否將視您的系統及印表機而定。 如果您選擇了一個您的系統所無法顯示或是並未安裝的字型,Windows 會以另一個類似的字型取代它。

範例

下列範例會使用 Print 方法來顯示名為 Report1 報表上的文字。 它會使用 TextWidthTextHeight 方法來垂直和水平置中的文字。

Private Sub Detail_Format(Cancel As Integer, _ 
 FormatCount As Integer) 
 Dim rpt as Report 
 Dim strMessage As String 
 Dim intHorSize As Integer, intVerSize As Integer 
 
 Set rpt = Me 
 strMessage = "DisplayMessage" 
 With rpt 
 'Set scale to pixels, and set FontName and 
 'FontSize properties. 
 .ScaleMode = 3 
 .FontName = "Courier" 
 .FontSize = 24 
 End With 
 ' Horizontal width. 
 intHorSize = Rpt.TextWidth(strMessage) 
 ' Vertical height. 
 intVerSize = Rpt.TextHeight(strMessage) 
 ' Calculate location of text to be displayed. 
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2) 
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2) 
 ' Print text on Report object. 
 Rpt.Print strMessage 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應