印刷設定(フッターに画像を指定)LeftFooterPicture,CenterFooterPicture,RightFooterPicture
フッターに画像を表示するには
- LeftFooterPicture プロパティ、CenterFooterPicture プロパティ、RightFooterPicture プロパティ を使用して、Graphic オブジェクト を取得します。
- Graphic オブジェクト で、表示する画像ファイルを取得(Filename プロパティ)します。また、その他、画像ファイルのさまざまな設定を行います。(詳細は、印刷設定(ヘッダー・フッターに画像を設定)Graphic オブジェクト を参照してください。)
- 実際に画像を表示するには、LeftFooter プロパティ、CenterFooter プロパティ、RightFooter プロパティ などに、VBA コードの「&G」を設定します。(VBA コード に関しては、印刷設定(ヘッダー/フッター)書式コード・VBAコード を参照してください。)
PageSetup.LeftFooterPicture プロパティ
PageSetup.LeftFooterPicture プロパティを使用して、左フッターに画像を表示するための設定を行います。実際に画像を表示するには、PageSetup.LeftFooter プロパティ に、VBA コード「&G」を指定します。
object.PageSetup.LeftFooterPicture
引数・戻り値
- object ・・・ 対象となる Worksheet オブジェクト を指定します。
- LeftFooterPicture プロパティで、Graphic オブジェクトを取得し、画像の設定を行います。
(例)画像(C:\Sample.bmp)を左フッターに表示する設定
With Activesheet.PageSetup
LeftFooterPicture.Filename = “C:\Sample.bmp”
LeftFooter = “&G”
End With
PageSetup.CenterFooterPicture プロパティ
PageSetup.CenterFooterPicture プロパティを使用して、フッター中央に画像を表示するための設定を行います。実際に画像を表示するには、PageSetup.CenterFooter プロパティ に、VBA コード「&G」を指定します。
object.PageSetup.CenterFooterPicture
引数・戻り値
- object ・・・ 対象となる Worksheet オブジェクト を指定します。
- CenterFooterPicture プロパティで、Graphic オブジェクトを取得し、画像の設定を行います。
(例)画像(C:\Sample.bmp)をヘッダー中央に表示する設定
With Activesheet.PageSetup
CenterFooterPicture.Filename = “C:\Sample.bmp”
CenterFooter = “&G”
End With
PageSetup.RightFooterPicture プロパティ
PageSetup.RightFooterPicture プロパティを使用して、右ヘッダーに画像を表示するための設定を行います。実際に画像を表示するには、PageSetup.RightFooter プロパティ に、VBA コード「&G」を指定します。
object.PageSetup.RightFooterPicture
引数・戻り値
- object ・・・ 対象となる Worksheet オブジェクト を指定します。
- RightFooterPicture プロパティで、Graphic オブジェクトを取得し、画像の設定を行います。
(例)画像(C:\Sample.bmp)を右ヘッダーに表示する設定
With Activesheet.PageSetup
RightFooterPicture.Filename = “C:\Sample.bmp”
RightFooter = “&G”
End With
フッターに画像を設定する
サンプルVBAソース
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
Sub Sample_HeaderFooter04() Dim w As Worksheet Dim pict As String Set w = ActiveSheet pict = CreateObject("WScript.Shell").SpecialFolders("MyDocuments") & "/sample02.jpg" 'プリンタとの通信を遮断(印刷設定を高速化) Application.PrintCommunication = False With w.PageSetup '表示する画像のパス&名前 .LeftFooterPicture.Filename = pict '画像の縦横サイズを個別に指定 .LeftFooterPicture.LockAspectRatio = False '元画像のサイズ 500 .LeftFooterPicture.Width = 250 '元画像のサイズ 250 .LeftFooterPicture.Height = 250 '画像の色(グレースケール) .LeftFooterPicture.ColorType = msoPictureGrayscale '画像の明度( 40% ) .LeftFooterPicture.Brightness = 0.4 '画像のコントラスト( 35% ) .LeftFooterPicture.Contrast = 0.35 '左フッターに画像を表示 .LeftFooter = "&G" End With 'プリンタとの通信を再開 Application.PrintCommunication = True 'プレビュー表示 w.PrintPreview End Sub |
実行結果
サンプルVBAソース 実行結果
設定画面を表示
[ページ設定] – [ヘッダー/フッター] タブ を選択し[ヘッダーの編集]
「中央部」にカーソルを移動して、[図の書式設定] をクリック
ヘッダーに表示した画像の原画
関連記事
-
ブックの変更が保存されているかを確認する(Saved プロパティ)
ブックの変更が保存されているかを確認する(Saved プロパティ) Saved …
-
選択されているシートを参照する(SelectedSheets プロパティ)
SelectedSheets プロパティ 選択されているすべてのシートをあらわす …
-
ウィンドウ枠の固定(FreezePanes プロパティ、SplitColumn プロパティ,SplitRow プロパティ)
ウィンドウ枠の固定と解除 ウィンドウ枠を固定するには FreezePanes プ …
-
WorksheetView オブジェクト
WorkSheetView オブジェクト 行列番号や枠線の表示・非表示の設定など …
-
ウィンドウを拡大・縮小(Zoom プロパティ)
ウィンドウを拡大・縮小(Zoom プロパティ) ウィンドウの表示サイズをパーセン …
-
ワークシートを参照する(Sheets プロパティ)
Sheets プロパティ Sheets プロパティは、Sheets コレクション …
-
ユーザー設定のビュー(CustomView オブジェクト)
ユーザー設定のビュー CustomView オブジェクトは、登録されている各ビュ …
-
白黒印刷(PageSetup.BlackAndWhite プロパティ)
PageSetup.BlackAndWhite プロパティ PageSetup. …
-
スクロールバーの表示・非表示(DisplayHorizontalScrollBar,DisplayVerticalScrollBar)
スクロールバーの表示・非表示の設定 Windows オブジェクト の Displ …
-
ブックを参照(Workbooks プロパティ,Windows プロパティ)
アクティブなワークブックを参照 現在使用中のワークブック、複数ある場合は一番手前 …