Macro-inserted pictures are not showing on other computers

alialeola

New Member
Joined
Jul 6, 2022
Messages
25
Platform
  1. Windows
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.

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!
 

Attachments

  • WhatsApp Image 2024-07-18 at 15.06.33_a2ee6316.jpg
    WhatsApp Image 2024-07-18 at 15.06.33_a2ee6316.jpg
    10.2 KB · Views: 21

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
The pictures are selected from a target folder... does every computer have the target folder? Dave
 
Upvote 0
The pictures are selected from a target folder... does every computer have the target folder? Dave
Nup, the purpose is to send these files to external contacts :/

The photos should be added/embedded in the spreadsheet..

.. now how do I do that, Dave please?
 
Upvote 0
If you run your code and then save the file, don't the pictures remain with the wb? Dave
ps. The file size will become quite large if you save a lot of pics
To compress the pics after adding them you can trial this code...
VBA Code:
VBA.SendKeys "%W{ENTER}", True
Application.CommandBars.ExecuteMso ("PicturesCompress")
 
Upvote 0
If you run your code and then save the file, don't the pictures remain with the wb? Dave
ps. The file size will become quite large if you save a lot of pics
To compress the pics after adding them you can trial this code...
VBA Code:
VBA.SendKeys "%W{ENTER}", True
Application.CommandBars.ExecuteMso ("PicturesCompress")
Actually, the pictures remain in the wb.
The problem is that they are not displayed after transferring the files on other computers.
 
Upvote 0
If you send the WB to the person who cannot see the pics, and they send it back to you, can you still see the pics on the returned copy?
 
Upvote 0
If you send the WB to the person who cannot see the pics, and they send it back to you, can you still see the pics on the returned copy?
In Protected View mode, no. After I enable editing, they are displayed.
 

Attachments

  • Screenshot 2024-07-19 103106.jpg
    Screenshot 2024-07-19 103106.jpg
    65.3 KB · Views: 11
Upvote 0
It might be a good idea to check that their workbook settings are not hiding objects:

File -> Options -> Advanced -> Display options for this workbook -> For objects, show:

Set to "All"
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top