ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   need help importing photos from file folders (https://www.excelbanter.com/excel-programming/314224-need-help-importing-photos-file-folders.html)

wraithlead[_6_]

need help importing photos from file folders
 

I don't even know if anyone is still up...

ActiveSheet.Pictures.Insert(loc1).Select

I have that line of code to insert a photo. loc1 is hardcoded to go to
a certain cell and load the text containing a path.

the path is:

I:\Lab\Perf\Test Reports\For Lab Only\Test Reports for 2004
Requests\P04332\Defrost Pictures\13 5 Volts\Salt Water
Resistance\Sample Number 7 RH\MVC-001F.JPG

where everything after "defrost pictures" could change.

Is there a way to load every photo regardless of how many there are?

I wanted a dynamic way to load all the photos in the "sample number 7
rh" folder, then change only "sample number 8 rh".

thanks,
richard


--
wraithlead
------------------------------------------------------------------------
wraithlead's Profile: http://www.excelforum.com/member.php...o&userid=11578
View this thread: http://www.excelforum.com/showthread...hreadid=271074


Dave Peterson[_3_]

need help importing photos from file folders
 
Maybe something like this will get you started:


Option Explicit
Sub testme()

Application.ScreenUpdating = False

Dim myPath As String
Dim iCtr As Long
Dim myRng As Range
Dim myPict As Picture

'change to point at the folder to check
myPath = "c:\my documents\my pictures"

With Application.FileSearch
.NewSearch
'Change this to your directory
.LookIn = myPath
.Filename = ".jpg"
.SearchSubFolders = True
If .Execute() 0 Then
Set myRng = ActiveSheet.Range("a1:b2")
For iCtr = 1 To .FoundFiles.Count
Set myPict = ActiveSheet.Pictures.Insert(.FoundFiles(iCtr))
With myPict
.Width = myRng.Width
.Top = myRng.Top
.Height = myRng.Height
.Left = myRng.Left
.Name = "Pict_" & myRng.Address(0, 0)
End With
Set myRng = myRng.Offset(2, 0)
Next iCtr
End If
End With

Application.ScreenUpdating = True
End Sub



wraithlead wrote:

I don't even know if anyone is still up...

ActiveSheet.Pictures.Insert(loc1).Select

I have that line of code to insert a photo. loc1 is hardcoded to go to
a certain cell and load the text containing a path.

the path is:

I:\Lab\Perf\Test Reports\For Lab Only\Test Reports for 2004
Requests\P04332\Defrost Pictures\13 5 Volts\Salt Water
Resistance\Sample Number 7 RH\MVC-001F.JPG

where everything after "defrost pictures" could change.

Is there a way to load every photo regardless of how many there are?

I wanted a dynamic way to load all the photos in the "sample number 7
rh" folder, then change only "sample number 8 rh".

thanks,
richard

--
wraithlead
------------------------------------------------------------------------
wraithlead's Profile: http://www.excelforum.com/member.php...o&userid=11578
View this thread: http://www.excelforum.com/showthread...hreadid=271074


--

Dave Peterson



All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com