ホーム :画像関連 :


指定セルに画像読出し

前へ 次へ

B4セルに、選択した画像(picture)を読み出す。

Sub gazou_yomidasi()
Dim strFNAME As String 'ファイル名
Dim 倍率 As Single

Application.ScreenUpdating = False

strFNAME = ""
strFNAME = Application.GetOpenFilename("画像 ,*.jpg; *.gif; *.bmp")
If VarType(strFNAME) = vbBoolean Then Exit Sub
If strFNAME = "False" Then Exit Sub ' キャンセルした場合。

倍率 = Range("b3").Value
On Error Resume Next
Module1.gazou_kesu

Range("B4").Select
ActiveSheet.Pictures.Insert(strFNAME).Select

Selection.ShapeRange.ScaleWidth 倍率, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 倍率, msoFalse, msoScaleFromTopLeft


End Sub

'-------------------------------------------------------------------

Sub gazou_kesu()

For Each mySh In ActiveSheet.Pictures
With mySh
If .TopLeftCell = Range("b4") Then
.Delete
End If
End With
Next

End Sub



前へ 次へ
画像関連 に戻る