1
2

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.

ExcelにCtrl + Vでスクショを貼り付けるとサイズが大きくなるのを解消するマクロ

Last updated at Posted at 2021-04-09
Option Explicit

Sub MiniScreenShotShortCut()
    Application.MacroOptions Macro:="HeightBaseMiniScreenShot", ShortcutKey:="e"
    Application.MacroOptions Macro:="WidthBaseMiniScreenShot", ShortcutKey:="E"
End Sub

Sub HeightBaseMiniScreenShot()
    
    Dim expectHeight As Double
    
    'リサイズ後のスクショの高さ
    expectHeight = 500
    
    Dim cbfs As Variant
    
    cbfs = Application.ClipboardFormats
    
    If cbfs(1) = xlClipboardFormatBitmap Or cbfs(1) = xlClipboardFormatPICT Then
        ActiveSheet.Paste
        
        Selection.Height = expectHeight
        
        Dim moveCount As Integer
        moveCount = Selection.Height \ ActiveCell.RowHeight + 1
        
        ActiveCell.Offset(moveCount, 0).Activate
    End If
    
End Sub

Sub WidthBaseMiniScreenShot()
    
    Dim expectWidth As Double
    
    'リサイズ後のスクショの幅
    expectWidth = 500
    
    Dim cbfs As Variant
    
    cbfs = Application.ClipboardFormats
    
    If cbfs(1) = xlClipboardFormatBitmap Or cbfs(1) = xlClipboardFormatPICT Then
        ActiveSheet.Paste
        
        Selection.Width = expectWidth
        
        Dim moveCount As Integer
        moveCount = Selection.Height \ ActiveCell.RowHeight + 1
        
        ActiveCell.Offset(moveCount, 0).Activate
    End If
    
End Sub

Ctrl + E で高さ固定、Ctrl + Shift + E で幅固定でクリップボードに入っている画像をリサイズして貼り付けられます。
個人的な都合でリサイズしたスクショを貼り付けたときにフォーカスをスクショの高さだけ下に移動させています。邪魔なら消してください。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?