Link to home
Start Free TrialLog in
Avatar of jppinto
jppintoFlag for Portugal

asked on

Pictures not displaying on sheet

I've the code below to insert pictures on a Excel sheet. The pictures are on a network drive. This works fine and I can see the pictures on my computer when I open the file.
If I save the file on another PC and try to open it, I can't see the pictures and instead of the picture I get the message displayed on the attached image.

I'm working with Excel 2010. Three months ago I was working with Excel 2003 and I didn't had this problem. I only have this problem since our company upgraded to Excel 2010.

Can annyone please help me understand what I'm missing here?

Thanks,

jppinto
Sub InsereFotografia()
On Error Resume Next
   Dim result() As String
   result = Split(ActiveCell.Value, "-")
    
   Dim num As Long
   num = result(0)
   
   ActiveCell.Offset(-2, 0).Select
    
   ActiveSheet.Pictures.Insert( _
        "P:\Backup Montagem Final\ARQUIVO\Agenda MF 2011\FOTOS MF 2011\000" & num & ".JPG").Select
End Sub

Open in new window

Capturar.JPG
SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jppinto

ASKER

On the machines that don't see the pictures, they don't have access to that drive.
What I can add to the problem is, when using Excel 2003, when I ran this code, the pictures where embended into the Excel sheet, so the size of the file would grow substancially. Now, I've added like 1000 pictures using the same code and the file still has less that 1Mb! This has happened with other files where I've used this code and only after the Office upgrade.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jppinto

ASKER

I've already tryed without the .Select statment and the result is the same. I tryed changing name of the folder where the pictures are and when I open the file, the pictures are gone from the sheet! I change the name of the folder back to it's original name and the pictures appear!
Avatar of jppinto

ASKER

Also, I'm checking this on my home laptop, not on any company computer.
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
jppinto,

you say

>> On the machines that don't see the pictures, they don't have access to that drive.

So there's the problem. They don't have access to the drive.

You need to ensure that the source of the files is accessible to the user who is opening the Excel workbook. Whatever version you are using.

>> Also, I'm checking this on my home laptop, not on any company computer.

On your home laptop, can you access the files in Windows Explorer with the "P:\" drive mapping?

If the pictures are not embedded (to save disk space), then of course the user needs to have access to the link location and it needs to have the same drive mapping as the one the linked picture is using.

cheers, teylyn
Avatar of jppinto

ASKER

Hello teylyn,

Yes, I understand that if I don't have access to the drive where the pictures are, I can't see them on my sheet. They are linked and not embedded on my sheet, but that's my problem...why are they getting linked instead of embedded on the sheet?!? How can I get the pictures to be embedded on the sheet instead of linked? Do I need to change annything on my code? I'm I doing something wrong?

Thanks for your support on this one.

jppinto
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jppinto

ASKER

I teylyn,

I also found the code that you posted. No luck again because the picutures also get linked, not embedded!

jppinto
Here's the suggestion from the MS help files (or the not very HELPful FILES):


If you sent your document through e-mail or copied it to a network file server, and your picture or clip is linked (linked object: An object that is created in a source file and inserted into a destination file, while maintaining a connection between the two files. The linked object in the destination file can be updated when the source file is updated.) and not embedded (embedded object: Information (object) contained in a source file and inserted into a destination file. Once embedded, the object becomes part of the destination file. Changes you make to the embedded object are reflected in the destination file.), send the picture or clip files through e-mail with your document, or copy the picture or clip files to the same network file folder that contains your document.


 Tip   In Microsoft Office PowerPoint 2007, you can use the Package for CD feature to update the links and bundle the associated files.


--
One thought is that you can use a VB picturebox that, I think lets you embed the picture.  Then you can move it over when the form is opened.  Seems rather silly to do that, but maybe worth a try.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jppinto

ASKER

This must be an Excel 2010 bug!

You can insert picture and you have the option to "Insert", "Link to File" or "Insert and Link" by clicking on the Insert button on the bottom of the insert dialog box. If you record a macro and insert a picture onto your sheet and select the option "Insert", then insert another picture and select the "Link to File", the code that you get is exactly the same.

If I run my macro on a Excel 2010 computer the pictures appear linked, if I run my macro on an Excel 2003 computer, the pictures are embedded into the Excel file and I can send to people that don't have access to the folder where the original pictures are!

jppinto
Capture.JPG
Just a thought...maybe you have to save it as an xlsb file?
Avatar of jppinto

ASKER

As this looks like an Excel 2010 bug, and the solutions presented by teylyn and rorya can serve as a walkaround to the problem, I've split the points among the participants on this question to reward your participation. Hope that this is fair for you.
As mentioned before, the way I "solved" the problem was running the macro on a PC with Office 2003. This way the pictures get embedded on the sheet and my problem is solved.

Thanks again for your participation. It let me to find my own solution.

jppinto
Thanks, and good to know about this.  Sounds like the 2007/2010 rewrite of Excel didn't properly handle embedded images.  Hopefully this gets fixed with a patch in the future.