카테고리 없음

엑셀 vba로 셀에 입력된 텍스트, 소스형태 이미지 출력하기

낌준희 Kkimjunhee 2023. 3. 27. 18:12
반응형

Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("G2:G130")
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 1
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
If .Width > xRg.Width Then .Width = xRg.Width * 4 / 5
If .Height > xRg.Height Then .Height = xRg.Height * 4 / 5
.Top = xRg.Top + (xRg.Height - .Height) / 4
.Left = xRg.Left + (xRg.Width - .Width) / 4
End With
lab:
Set Pshp = Nothing
Range("G2").Select
Next
Application.ScreenUpdating = True
End Sub

 

위 소스를 활용하면, G열의 이미지를, H열에 맞춰서 출력해준다.

반응형