Hi guys,
I have this below piece of code that is adding pictures to my excel files.
The problem is that while I can see the photos just fine, they are not displayed on other computers.
Any idea what the problem might be pls?
I didn't write the code, so if any adjustments are needed, I would greatly appreciate the full instructions.
Thanks!
I have this below piece of code that is adding pictures to my excel files.
The problem is that while I can see the photos just fine, they are not displayed on other computers.
Any idea what the problem might be pls?
I didn't write the code, so if any adjustments are needed, I would greatly appreciate the full instructions.
VBA Code:
Sub LoopThroughFiles()
Dim oFSO As Object
Dim oFolder As Object
Dim oFile As Object
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = -1 Then
targetfolder = .SelectedItems(1)
End If
End With
If targetfolder = "" Then Exit Sub
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(targetfolder)
With ActiveSheet
For Each c In .Range("A1", "A" & .UsedRange.Rows.Count)
Debug.Print "looking for pic " & c.Value
For Each oFile In oFolder.Files
If c.Value = oFile.Name Then
c.Select
Set Pict = ActiveSheet.Pictures.Insert(targetfolder & "\" & oFile.Name)
With Pict
.ShapeRange.LockAspectRatio = msoFalse
.Top = c.Top
.Left = c.Left
.Width = c.Width
.Height = c.Height
End With
End If
Next oFile
Next c
End With
End Sub
Thanks!