印刷位置を中央に設定(CenterHorizontally, CenterVertically)
PageSetup.CenterHorizontally プロパティ
PageSetup.CenterHorizontally プロパティを使用して、印刷位置を水平方向の中央(余白を除く)に設定することができます。値の取得および設定が可能で、ブール型(Boolean)の値を使用します。
<取得>
object.PageSetup.CenterHorizontally
<設定>
object.PageSetup.CenterHorizontally = boolean
引数・戻り値
- object ・・・ 対象となる Worksheet オブジェクト を指定します。
- boolean ・・・ ブール型(Boolean)の値を指定します。True を指定すると、印刷位置を水平方向の中央(余白を除く)に設定します。
PageSetup.CenterVertically プロパティ
PageSetup.CenterVertically プロパティを使用して、印刷位置を垂直方向の中央(余白を除く)に設定することができます。値の取得および設定が可能で、ブール型(Boolean)の値を使用します。
<取得>
object.PageSetup.CenterVertically
<設定>
object.PageSetup.CenterVertically = boolean
引数・戻り値
- object ・・・ 対象となる Worksheet オブジェクト を指定します。
- boolean ・・・ ブール型(Boolean)の値を指定します。True を指定すると、印刷位置を垂直方向の中央(余白を除く)に設定します。
CenterHorizontally プロパティ・CenterVertically プロパティ 使用例
サンプルVBAソース
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Sub Sample_Center() Dim w As Worksheet Set w = ActiveSheet '用紙の中央(余白除く)に印刷するように設定 w.PageSetup.CenterHorizontally = True w.PageSetup.CenterVertically = True '印刷プレビューを表示 w.PrintPreview End Sub |
実行結果
関連記事
-
行列の見出しの表示・非表示(DisplayHeadings プロパティ)
DisplayHeadings プロパティ 行と列の見出しの表示・非表示を設定お …
-
表示されているセル範囲を取得(VisibleRange プロパティ)
VisibleRange プロパティ 現在表示されているセル範囲(Range オ …
-
印刷のタイトル行、タイトル列を設定(PrintTitleRows,PrintTitleColumns)
PageSetup.PrintTitleRows プロパティ PageSetup …
-
ワークシートの数を数える(Count プロパティ)
Count プロパティ 指定したWorksheets コレクションやSheets …
-
印刷範囲の設定・解除(PageSetup.PrintArea プロパティ)
PageSetup.PrintArea プロパティ 印刷範囲を設定するには、Pa …
-
ブック・シートの名前を取得・設定(Name プロパティ)
ワークブックの名前を取得 Name プロパティで、ワークブックの名前を取得します …
-
印刷時、シート内のエラーをどう扱うかを設定(PrintErrors プロパティ)
PageSetup.PrintErrors プロパティ PageSetup.Pr …
-
共有ファイルを開いているユーザー情報を取得(UserStatus プロパティ)
共有ファイルを開いているユーザー情報を取得 UserStatus プロパティは、 …
-
ブックのパスを取得(FullName プロパティ,Path プロパティ)
FullName プロパティ・Path プロパティ ブックのパス(保存場所)を調 …
-
シートを保護・保護したシートを解除する(Protect メソッド・Unprotect メソッド)
Protect メソッド・Unprotect メソッド Protect メソッド …