Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Inserting all pictures from a certain file folder

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   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Inserting all pictures from a certain file folder

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you export pictures from my pictures file into a word docu Becky New Users to Excel 1 November 20th 09 07:02 PM
Inserting Pictures Based On File name Jeff W. Excel Programming 4 November 5th 07 12:04 AM
Storing Clip Art pictures in My Pictures folder jfg Excel Discussion (Misc queries) 4 August 10th 07 06:12 AM
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k[_40_] Excel Programming 6 August 11th 06 08:41 PM
inserting more than 65536 pictures into file using VBA maple3 Excel Programming 6 April 30th 06 01:02 AM


All times are GMT +1. The time now is 05:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"