Advertisement
baykaone

Untitled

Nov 17th, 2020 (edited)
1,408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub Import_img()
  2.     Dim path$, picpath$, sFile$, myPic As Object, ws As Worksheet, i%
  3.     Set ws = ActiveSheet
  4.     i = 1 ' first row
  5.    col = 1 ' column
  6.    path = "C:\images\" 'directory
  7.    
  8.     sFile = Dir$(path, vbNormal)
  9.     Do Until LenB(sFile) = 0
  10.         If sFile <> "." And sFile <> ".." Then
  11.             picpath = path & sFile
  12.             Set myPic = ws.Shapes.AddPicture(picpath, False, True, 0, 0, -1, -1)
  13.             With myPic
  14.                 .Height = Cells(i, col).Height
  15.                 .Top = Cells(i, col).Top
  16.                 .Left = Cells(i, col).Left
  17.                 .Name = sFile
  18.             End With
  19.             i = i + 1
  20.         End If
  21.         sFile = Dir$
  22.     Loop
  23. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement