印刷設定(フッターに画像を指定)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ソース 実行結果
設定画面を表示
[ページ設定] – [ヘッダー/フッター] タブ を選択し[ヘッダーの編集]
「中央部」にカーソルを移動して、[図の書式設定] をクリック
ヘッダーに表示した画像の原画
関連記事
-
-
スクロール範囲を限定(ScrollArea プロパティ)
ScrollArea プロパティ ScrollArea プロパティ にセル範囲を …
-
-
画面の上端・左端を設定(ScrollRow プロパティ、ScrollColumn プロパティ)
画面の上端・左端を設定 ScrollRow プロパティで、指定した行を画面上端に …
-
-
行列番号を含めて印刷(PageSetup.PrintHeadings プロパティ)
PageSetup.PrintHeadings プロパティ PageSetup. …
-
-
数式を表示(DisplayFormulas プロパティ)
数式を表示(DisplayFormulas プロパティ) セルに数式が入力されて …
-
-
数式バーの設定(DisplayFormulaBar, FormulaBarHeight)
数式バーの設定 数式バーの表示・非表示の設定を行うには、DisplayFormu …
-
-
印刷設定(先頭ページのヘッダー・フッターを設定)DifferentFirstPageHeaderFooter, FirstPage
先頭ページに別のヘッダーおよびフッターを設定 先頭ページのヘッダーおよびフッター …
-
-
印刷のタイトル行、タイトル列を設定(PrintTitleRows,PrintTitleColumns)
PageSetup.PrintTitleRows プロパティ PageSetup …
-
-
ブックの変更が保存されているかを確認する(Saved プロパティ)
ブックの変更が保存されているかを確認する(Saved プロパティ) Saved …
-
-
ウィンドウの状態を取得・設定(WindowState プロパティ)
ウィンドウの状態を取得・設定(WindowState プロパティ) Window …
-
-
新しいウィンドウを開く(NewWindow メソッド)
NewWindow メソッド NewWindow メソッドで、任意のブックのコピ …