Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave, thanks for pointing that out.
The code inbetween the loop is something which the OP already have. I have mentioned in my post to adjust the range to suit the requirement. If this post helps click Yes --------------- Jacob Skaria "Dave Peterson" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do you export pictures from my pictures file into a word docu | New Users to Excel | |||
Inserting Pictures Based On File name | Excel Programming | |||
Storing Clip Art pictures in My Pictures folder | Excel Discussion (Misc queries) | |||
Save file in a new folder, but create folder only if folder doesn't already exist? | Excel Programming | |||
inserting more than 65536 pictures into file using VBA | Excel Programming |