PDA

View Full Version : click a button to open a picture



clarksonneo
12-03-2010, 07:19 PM
Hi,

I want to click a button in an Excel file to open a picture in a folder my company, eg ("C:\Users\XX\Desktop\FOLDER1\1.jpg")

How can I do that?

Thanks

Sean.DiSanti
12-03-2010, 07:43 PM
the easiest way would be to use Shell to call a program passing the file name as a parameter... like:
Shell "mspaint.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"

clarksonneo
12-04-2010, 01:41 AM
the easiest way would be to use Shell to call a program passing the file name as a parameter... like:
Shell "mspaint.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"
Thank you for your reply.
Your code is work.

However, i don't want to use mspaint to open the photo.

I have tried to use "WLXPhotoGallery.exe"
it is at C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery


However, my code is not work

Sub photo_Click()

Shell "WLXPhotoGallery.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"

End Sub



Could you please tell me any mistake on my code?
I think the problem is at WLXPhotoGallery.exe



On the other hand, how can i insert a picture by checking a button?

Thanks

Sean.DiSanti
12-04-2010, 11:18 AM
use the full path:
Shell "C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery\WLXPhotoGallery.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"
i didn't list the path in mine because mspaint is located in system32 and can be called without the path written out.

Bob Phillips
12-04-2010, 01:28 PM
What do you mean by open? Are you trying to insert it into a spreadsheet?

Sean.DiSanti
12-04-2010, 01:35 PM
it looks like he wants to open it in another program, i think this one can be marked solved

clarksonneo
12-04-2010, 04:04 PM
use the full path:
Shell "C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery\WLXPhotoGallery.exe C:\Users\XX\Desktop\FOLDER1\1.jpg" i didn't list the path in mine because mspaint is located in system32 and can be called without the path written out.
hi Sean.DiSanti,
Your code does work.
However, the picture will be closed automatically just after it opens.



it looks like he wants to open it in another program
yes

Sean.DiSanti
12-04-2010, 04:11 PM
closed automatically? it shouldn't be

clarksonneo
12-05-2010, 12:47 AM
closed automatically? it shouldn't be

closed automatically? it shouldn't be
yes closed automatically.

Now, I use another way

ActiveSheet.Pictures.Insert (" file' location + flie's name)

This work.
It inserts a picure instead of opening the picture by another program

Thanks