View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Inserting all pictures from a certain file folder

That'll put all the pictures in one location.

Maybe...

Option Explicit

Sub Macro()

Dim strFolder As String
Dim strFile As String
Dim YourPic As Picture
Dim DestCell As Range

Set DestCell = ActiveSheet.Range("C3")

strFolder = "c:\temp\"

strFile = Dir(strFolder & "*.jpg", vbNormal)
Do While strFile < ""
With DestCell
Set YourPic = .Parent.Pictures.Insert(strFolder & strFile)
YourPic.Top = .Top
YourPic.Width = .Width
YourPic.Height = .Height
YourPic.Left = .Left
End With

Set DestCell = DestCell.Offset(1, 0)

strFile = Dir
Loop

End Sub

Jacob Skaria wrote:

Try the below macro. Change the folder name to suit your requirement..You
will neeed to adjust the Range to a variable to suit...

Sub Macro()

Dim strFolder As String
Dim strFile As String
Dim YourPic As Picture

strFolder = "c:\temp\"

strFile = Dir(strFolder & "*.jpg", vbNormal)
Do While strFile < ""

With ActiveSheet.Range("C3")
Set YourPic = .Parent.Pictures.Insert(strFolder & strFile)
YourPic.Top = .Top
YourPic.Width = .Width
YourPic.Height = .Height
YourPic.Left = .Left
End With

strFile = Dir
Loop

End Sub

If this post helps click Yes
---------------
Jacob Skaria

"ironhydroxide" wrote:

I know how insert pictures when i know the exact file name, and i learned how
to have the computer ask which file i want to insert, but how would someone
insert all the pictures from a certain file folder?


--

Dave Peterson