0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【PowerPoint】指定名Shapeの表示/非表示を切り替えて擬似的にスライドに余白設定する【VBA】

Last updated at Posted at 2022-02-25

PowerPointにはどうやら図形の印刷をしない設定がないっぽい

なので下図の様に余白を図形で作って印刷時に表示しないようにして対処してみた。

下図の様に余白を図形を作り、"shp余白"と命名。

image.png

作り方は四角形2つを重ねて、図形の結合から「型抜き」する。

image.png

image.png

作った余白を全スライドに複製する

Sub ppShape複製()

  ActivePresentation.Slides(1).Shapes("shp余白").Copy

  Dim sld As PowerPoint.Slide
  Dim shp As PowerPoint.Shape
  
  For Each sld In ActivePresentation.Slides
    sld.Shapes.Paste
  Next

End Sub

余白の表示切替をする

Sub pp余白の表示切替()
  Const shpName = "shp余白"
  Static v
  v = ActivePresentation.Slides(1).Shapes(shpName).Visible
  Call ppShape非表示にする(shpName, Not (v))
  
End Sub

Sub ppShape非表示にする(shpName As String, Is表示する As Boolean)
  
  Dim sld As PowerPoint.Slide
  Dim shp As PowerPoint.Shape
  
  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes
      If shp.Name = shpName Then
        shp.Visible = Is表示する
        Exit For
      End If
    Next
  Next

End Sub

印刷時に余白を非表示にする

Excelと違って印刷イベントがないのでpdf出力マクロに図形の非表示プロシージャを入れておく。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?