
前回の、「画像を挿入するマクロ」から少し改造して、挿入した画像を拡大してみます。
Sub button1_Click() Range("C7").Select ActiveSheet.Pictures.Insert "C:\work\Excel\neko01.jpg" Dim cnt As Integer cnt = ActiveSheet.Shapes.Count '挿入した画像選択して名前を付ける ActiveSheet.Shapes(cnt).Select Selection.ShapeRange.Name = "image1" '画像の拡大 With ActiveSheet.Shapes("image1") .LockAspectRatio = True '縦横比を固定 .Width = 300 '幅を指定(ポイント) End With End Subまず、挿入した画像を選択して名前を付けます。
そして、LockAspectRatioをTrueにして縦横比を固定にした状態で、幅を指定しています。
ちなみに、幅の単位はポイントです。
実行結果

スポンサーリンク