関数・メソッド

Excelの標準フォントサイズを設定/取得する【StandardFontSizeプロパティ】【ExcelVBA】

構文

Application.StandardFontSize

StandardFontSize・・・Excelアプリケーションの標準フォントサイズを取得/設定

Applicationオブジェクトの StandardFontSize プロパティでExcelの標準フォントサイズを取得/反映します。

StandardFontSizeプロパティのサンプルコード

Public Sub sample()

    '■セルA1のフォントサイズを「標準フォントサイズ」にする
    Range("A1").Font.Size = Application.StandardFontSize
    
    '■セルA1を含む表に対して、フォントサイズを「標準フォントサイズ」にする
    Range("A1").CurrentRegion.Font.Size = Application.StandardFontSize
                
    '■シート全体のフォントサイズを「標準フォントサイズ」にする
    Cells.Font.Size = Application.StandardFontSize

    '■セルA1のフォントサイズを標準フォントサイズへ設定する
    Application.StandardFontSize = Range("A1").Font.Size

    '■「10」ポイントを標準フォントサイズへ設定する
    Application.StandardFontSize = "MS Pゴシック"
    
    '■現在設定されている標準フォントサイズを取得する
    Debug.Print Application.StandardFontSize    '10
    
End Sub

注意点

  • セルのフォントサイズを取得や設定する場合はFont.Nameプロパティを使用します。
  • StandardFontSizeプロパティが反映されるのは、Excelの再起動後です。
    変更後に新規で開くすべてのExcelブックに適用されます。

関連記事

コメント

タイトルとURLをコピーしました