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 1 year has passed since last update.

Word VBA

Last updated at Posted at 2024-05-19

スクリーンショットをペーストした後にサイズを調整、そのままワードの作業が続けられるようにする。

Sub ResizeAndInsertReturn()
    Dim sel As Selection
    Set sel = Selection

    ' 縮小率を設定(40%)
    Dim scaleFactor As Single
    scaleFactor = 0.4

    ' 選択しているオブジェクトをチェック
    If sel.Type = wdSelectionInlineShape Then
        With sel.InlineShapes(1)
            ' オブジェクトのサイズを縮小
            .ScaleHeight = .ScaleHeight * scaleFactor
            .ScaleWidth = .ScaleWidth * scaleFactor
        End With
    ElseIf sel.Type = wdSelectionShape Then
        With sel.ShapeRange(1)
            ' オブジェクトのサイズを縮小
            .ScaleHeight factor:=scaleFactor, RelativeToOriginalSize:=msoFalse
            .ScaleWidth factor:=scaleFactor, RelativeToOriginalSize:=msoFalse
        End With
    Else
        MsgBox "選択しているオブジェクトがありません。"
        Exit Sub
    End If

    ' リターンキー(改行)を挿入
    sel.TypeParagraph
End Sub

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?